Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
AE UTBM
Sith
Commits
23291ac6
Commit
23291ac6
authored
Apr 26, 2018
by
Skia
🤘
Browse files
Merge branch 'bugfix' into 'master'
Forum and Com fixes See merge request ae/Sith!147
parents
0cc37070
83f38e61
Pipeline
#1484
passed with stage
in 11 minutes and 38 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
com/views.py
View file @
23291ac6
...
...
@@ -58,7 +58,6 @@ class PosterForm(forms.ModelForm):
fields
=
[
'name'
,
'file'
,
'club'
,
'screens'
,
'date_begin'
,
'date_end'
,
'display_time'
]
widgets
=
{
'screens'
:
forms
.
CheckboxSelectMultiple
,
'is_moderated'
:
forms
.
HiddenInput
()
}
date_begin
=
forms
.
DateTimeField
([
'%Y-%m-%d %H:%M:%S'
],
label
=
_
(
"Start date"
),
...
...
@@ -72,7 +71,7 @@ class PosterForm(forms.ModelForm):
if
self
.
user
:
if
not
self
.
user
.
is_com_admin
:
self
.
fields
[
'club'
].
queryset
=
Club
.
objects
.
filter
(
id__in
=
self
.
user
.
clubs_with_rights
)
self
.
fields
[
'display_time'
].
widget
=
forms
.
HiddenInput
(
)
self
.
fields
.
pop
(
'display_time'
)
class
ComTabsMixin
(
TabedViewMixin
):
...
...
@@ -572,6 +571,18 @@ class PosterEditBaseView(UpdateView):
form_class
=
PosterForm
template_name
=
'com/poster_edit.jinja'
def
get_initial
(
self
):
init
=
{}
try
:
init
[
'date_begin'
]
=
self
.
object
.
date_begin
.
strftime
(
'%Y-%m-%d %H:%M:%S'
)
except
Exception
:
pass
try
:
init
[
'date_end'
]
=
self
.
object
.
date_end
.
strftime
(
'%Y-%m-%d %H:%M:%S'
)
except
Exception
:
pass
return
init
def
dispatch
(
self
,
request
,
*
args
,
**
kwargs
):
if
'club_id'
in
kwargs
and
kwargs
[
'club_id'
]:
try
:
...
...
forum/models.py
View file @
23291ac6
...
...
@@ -31,6 +31,7 @@ from django.utils import timezone
from
django.utils.functional
import
cached_property
from
datetime
import
datetime
from
itertools
import
chain
import
pytz
from
core.models
import
User
,
Group
...
...
@@ -143,6 +144,9 @@ class Forum(models.Model):
def
__str__
(
self
):
return
"%s"
%
(
self
.
name
)
def
get_full_name
(
self
):
return
'/'
.
join
(
chain
.
from_iterable
([[
parent
.
name
for
parent
in
self
.
get_parent_list
()],
[
self
.
name
]]))
def
get_absolute_url
(
self
):
return
reverse
(
'forum:view_forum'
,
kwargs
=
{
'forum_id'
:
self
.
id
})
...
...
forum/templates/forum/forum.jinja
View file @
23291ac6
...
...
@@ -16,7 +16,7 @@
<div
id=
"forum"
>
<h3>
{{
forum.name
}}
</h3>
<p>
{%
if
user.is_in_group
(
settings.SITH_GROUP_FORUM_ADMIN_ID
)
or
user.is_in_group
(
settings.SITH_GROUP_COM_ADMIN_ID
)
%}
{%
if
user.is_in_group
(
settings.SITH_GROUP_FORUM_ADMIN_ID
)
or
user.is_in_group
(
settings.SITH_GROUP_COM_ADMIN_ID
)
or
user.can_edit
(
forum
)
%}
<a
class=
"ib button"
href=
"
{{
url
(
'forum:new_forum'
)
}}
?parent=
{{
forum.id
}}
"
>
{%
trans
%}
New forum
{%
endtrans
%}
</a>
<br/>
{%
endif
%}
{%
if
not
forum.is_category
%}
...
...
forum/views.py
View file @
23291ac6
...
...
@@ -71,6 +71,7 @@ class ForumFavoriteTopics(ListView):
topic_list
=
self
.
request
.
user
.
favorite_topics
.
all
()
return
topic_list
class
ForumLastUnread
(
ListView
):
model
=
ForumTopic
template_name
=
"forum/last_unread.jinja"
...
...
@@ -85,12 +86,18 @@ class ForumLastUnread(ListView):
return
topic_list
class
ForumNameField
(
forms
.
ModelChoiceField
):
def
label_from_instance
(
self
,
obj
):
return
obj
.
get_full_name
()
class
ForumForm
(
forms
.
ModelForm
):
class
Meta
:
model
=
Forum
fields
=
[
'name'
,
'parent'
,
'number'
,
'owner_club'
,
'is_category'
,
'edit_groups'
,
'view_groups'
]
edit_groups
=
make_ajax_field
(
Forum
,
'edit_groups'
,
'groups'
,
help_text
=
""
)
view_groups
=
make_ajax_field
(
Forum
,
'view_groups'
,
'groups'
,
help_text
=
""
)
parent
=
ForumNameField
(
Forum
.
objects
.
all
())
class
ForumCreateView
(
CanCreateMixin
,
CreateView
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment