Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
AE
Sith
Commits
f262014f
Commit
f262014f
authored
Feb 24, 2017
by
Skia
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Some various forum fixes and improvements
parent
d6b5db4a
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
20 additions
and
15 deletions
+20
-15
forum/templates/forum/forum.jinja
forum/templates/forum/forum.jinja
+3
-3
forum/templates/forum/macros.jinja
forum/templates/forum/macros.jinja
+2
-2
forum/templates/forum/main.jinja
forum/templates/forum/main.jinja
+1
-1
forum/templates/forum/topic.jinja
forum/templates/forum/topic.jinja
+3
-2
forum/views.py
forum/views.py
+11
-7
No files found.
forum/templates/forum/forum.jinja
View file @
f262014f
...
...
@@ -7,7 +7,7 @@
{%
block
content
%}
<div>
<a
href=
"
{{
url
(
'forum:main'
)
}}
"
>
Forum
</a>
<a
href=
"
{{
url
(
'forum:main'
)
}}
"
>
{%
trans
%}
Forum
{%
endtrans
%}
</a>
{%
for
f
in
forum.get_parent_list
()
%}
>
<a
href=
"
{{
f.get_absolute_url
()
}}
"
>
{{
f
}}
</a>
{%
endfor
%}
...
...
@@ -16,9 +16,9 @@
<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
)
%}
<a
href=
"
{{
url
(
'forum:new_forum'
)
}}
?parent=
{{
forum.id
}}
"
>
New forum
</a>
<br/>
<a
href=
"
{{
url
(
'forum:new_forum'
)
}}
?parent=
{{
forum.id
}}
"
>
{%
trans
%}
New forum
{%
endtrans
%}
</a>
<br/>
{%
endif
%}
<a
href=
"
{{
url
(
'forum:new_topic'
,
forum_id
=
forum.id
)
}}
"
>
New topic
</a>
<a
href=
"
{{
url
(
'forum:new_topic'
,
forum_id
=
forum.id
)
}}
"
>
{%
trans
%}
New topic
{%
endtrans
%}
</a>
</p>
{%
for
f
in
forum.children.all
()
%}
{{
display_forum
(
f
,
user
)
}}
...
...
forum/templates/forum/macros.jinja
View file @
f262014f
...
...
@@ -16,8 +16,8 @@
</div>
{%
endif
%}
{%
if
user.is_owner
(
forum
)
%}
<a
class=
"ib"
href=
"
{{
url
(
'forum:edit_forum'
,
forum_id
=
forum.id
)
}}
"
>
Edit
</a>
<a
class=
"ib"
href=
"
{{
url
(
'forum:delete_forum'
,
forum_id
=
forum.id
)
}}
"
>
Delete
</a>
<a
class=
"ib"
href=
"
{{
url
(
'forum:edit_forum'
,
forum_id
=
forum.id
)
}}
"
>
{%
trans
%}
Edit
{%
endtrans
%}
</a>
<a
class=
"ib"
href=
"
{{
url
(
'forum:delete_forum'
,
forum_id
=
forum.id
)
}}
"
>
{%
trans
%}
Delete
{%
endtrans
%}
</a>
{%
endif
%}
</div>
{%
if
not
forum.is_category
%}
...
...
forum/templates/forum/main.jinja
View file @
f262014f
...
...
@@ -8,7 +8,7 @@
{%
block
content
%}
<p>
<a
href=
"
{{
url
(
'forum:main'
)
}}
"
>
Forum
</a>
>
<a
href=
"
{{
url
(
'forum:main'
)
}}
"
>
{%
trans
%}
Forum
{%
endtrans
%}
</a>
>
</p>
<h3>
{%
trans
%}
Forum
{%
endtrans
%}
</h3>
<p>
...
...
forum/templates/forum/topic.jinja
View file @
f262014f
...
...
@@ -26,7 +26,7 @@
{%
block
content
%}
<p>
<a
href=
"
{{
url
(
'forum:main'
)
}}
"
>
Forum
</a>
<a
href=
"
{{
url
(
'forum:main'
)
}}
"
>
{%
trans
%}
Forum
{%
endtrans
%}
</a>
{%
for
f
in
topic.forum.get_parent_list
()
%}
>
<a
href=
"
{{
f.get_absolute_url
()
}}
"
>
{{
f
}}
</a>
{%
endfor
%}
...
...
@@ -52,7 +52,8 @@
<br/>
<strong>
{{
user_profile_link
(
m.author
)
}}
</strong>
</div>
<div
{%
if
m.id
==
first_unread_message_id
%}
id=
"first_unread"
{%
endif
%}
style=
"display: inline-block; width: 80%; vertical-align: top;"
>
<div
{%
if
m.id
==
first_unread_message_id
%}
id=
"first_unread"
{%
endif
%}
style=
"display: inline-block; width:
80%; vertical-align: top;
{%
if
m.deleted
%}
background: #FFAAAA;
{%
endif
%}
"
>
<div
style=
"display: inline-block; width: 74%;"
>
{%
if
m.title
%}
<h5>
{{
m.title
}}
</h5>
...
...
forum/views.py
View file @
f262014f
...
...
@@ -10,7 +10,7 @@ from django import forms
from
django.db
import
models
from
django.core.exceptions
import
PermissionDenied
import
math
from
ajax_select
import
make_ajax_form
,
make_ajax_field
from
core.views
import
CanViewMixin
,
CanEditMixin
,
CanEditPropMixin
,
CanCreateMixin
,
TabedViewMixin
from
forum.models
import
Forum
,
ForumMessage
,
ForumTopic
,
ForumMessageMeta
...
...
@@ -40,9 +40,16 @@ class ForumLastUnread(ListView):
date__gt
=
self
.
request
.
user
.
forum_infos
.
last_read_date
).
values_list
(
'topic'
)
# TODO try to do better
return
self
.
model
.
objects
.
filter
(
id__in
=
l
).
annotate
(
models
.
Max
(
'messages__date'
)).
order_by
(
'-messages__date__max'
).
select_related
(
'author'
)
class
ForumForm
(
forms
.
ModelForm
):
class
Meta
:
model
=
Forum
fields
=
[
'name'
,
'parent'
,
'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
=
""
)
class
ForumCreateView
(
CanCreateMixin
,
CreateView
):
model
=
Forum
f
ields
=
[
'name'
,
'parent'
,
'owner_club'
,
'is_category'
,
'edit_groups'
,
'view_groups'
]
f
orm_class
=
ForumForm
template_name
=
"core/create.jinja"
def
get_initial
(
self
):
...
...
@@ -54,10 +61,7 @@ class ForumCreateView(CanCreateMixin, CreateView):
except
:
pass
return
init
class
ForumEditForm
(
forms
.
ModelForm
):
class
Meta
:
model
=
Forum
fields
=
[
'name'
,
'parent'
,
'owner_club'
,
'is_category'
,
'edit_groups'
,
'view_groups'
]
class
ForumEditForm
(
ForumForm
):
recursive
=
forms
.
BooleanField
(
label
=
_
(
"Apply rights and club owner recursively"
),
required
=
False
)
class
ForumEditView
(
CanEditPropMixin
,
UpdateView
):
...
...
@@ -126,7 +130,7 @@ class ForumTopicDetailView(CanViewMixin, DetailView):
try
:
kwargs
[
'first_unread_message_id'
]
=
msg
.
id
except
:
kwargs
[
'first_unread_message_id'
]
=
math
.
inf
kwargs
[
'first_unread_message_id'
]
=
float
(
"
inf
"
)
return
kwargs
class
ForumMessageEditView
(
CanEditMixin
,
UpdateView
):
...
...
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