Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
AE
Sith
Commits
443616a7
Verified
Commit
443616a7
authored
Apr 26, 2018
by
Sli
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Forum permission fix and form display
parent
afa9bd87
Pipeline
#1480
passed with stage
in 12 minutes and 2 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
1 deletion
+14
-1
forum/models.py
forum/models.py
+6
-0
forum/templates/forum/forum.jinja
forum/templates/forum/forum.jinja
+1
-1
forum/views.py
forum/views.py
+7
-0
No files found.
forum/models.py
View file @
443616a7
...
...
@@ -143,6 +143,12 @@ class Forum(models.Model):
def
__str__
(
self
):
return
"%s"
%
(
self
.
name
)
def
get_full_name
(
self
):
name
=
''
for
parent
in
self
.
get_parent_list
():
name
+=
parent
.
name
+
'/'
return
name
+
self
.
name
def
get_absolute_url
(
self
):
return
reverse
(
'forum:view_forum'
,
kwargs
=
{
'forum_id'
:
self
.
id
})
...
...
forum/templates/forum/forum.jinja
View file @
443616a7
...
...
@@ -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 @
443616a7
...
...
@@ -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