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
777fdd7b
Commit
777fdd7b
authored
Feb 24, 2017
by
Skia
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Again, lot of forum improvements
parent
fe07ee09
Pipeline
#771
passed with stage
in 3 minutes and 29 seconds
Changes
8
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
158 additions
and
91 deletions
+158
-91
core/static/core/style.css
core/static/core/style.css
+4
-1
forum/models.py
forum/models.py
+3
-1
forum/templates/forum/forum.jinja
forum/templates/forum/forum.jinja
+7
-7
forum/templates/forum/macros.jinja
forum/templates/forum/macros.jinja
+54
-0
forum/templates/forum/reply.jinja
forum/templates/forum/reply.jinja
+35
-0
forum/templates/forum/topic.jinja
forum/templates/forum/topic.jinja
+9
-57
forum/views.py
forum/views.py
+6
-2
locale/fr/LC_MESSAGES/django.po
locale/fr/LC_MESSAGES/django.po
+40
-23
No files found.
core/static/core/style.css
View file @
777fdd7b
...
...
@@ -416,10 +416,13 @@ textarea {
margin
:
2px
;
background
:
#eff7ff
;
}
.message
:nth-child
(
odd
)
{
background
:
#fff
;
}
.message
h5
{
font-size
:
100%
;
}
.unread
{
.message
.unread
{
background
:
#d8e7f3
;
}
.msg_author.deleted
{
...
...
forum/models.py
View file @
777fdd7b
...
...
@@ -178,7 +178,9 @@ class ForumMessage(models.Model):
return
self
.
topic
.
get_absolute_url
()
+
"#msg_"
+
str
(
self
.
id
)
def
mark_as_read
(
self
,
user
):
self
.
readers
.
add
(
user
)
try
:
# Need the try/except because of AnonymousUser
self
.
readers
.
add
(
user
)
except
:
pass
def
is_read
(
self
,
user
):
return
(
self
.
date
<
user
.
forum_infos
.
last_read_date
)
or
(
user
in
self
.
readers
.
all
())
...
...
forum/templates/forum/forum.jinja
View file @
777fdd7b
...
...
@@ -23,14 +23,14 @@
{%
if
forum.children.exists
()
%}
<div>
<div
class=
"ib w_big"
>
Title
{%
trans
%}
Title
{%
endtrans
%}
</div>
<div
class=
"ib w_small"
>
<div
class=
"ib w_medium"
>
Topics
{%
trans
%}
Topics
{%
endtrans
%}
</div>
<div
class=
"ib w_small"
>
Last message
{%
trans
%}
Last message
{%
endtrans
%}
</div>
</div>
</div>
...
...
@@ -41,17 +41,17 @@
{%
if
topics
%}
<div>
<div
class=
"ib w_medium"
>
Title
{%
trans
%}
Title
{%
endtrans
%}
</div>
<div
class=
"ib w_medium"
>
<div
class=
"ib w_small"
>
Author
{%
trans
%}
Author
{%
endtrans
%}
</div>
<div
class=
"ib w_medium"
>
Messages
{%
trans
%}
Messages
{%
endtrans
%}
</div>
<div
class=
"ib w_small"
>
Last message
{%
trans
%}
Last message
{%
endtrans
%}
</div>
</div>
</div>
...
...
forum/templates/forum/macros.jinja
View file @
777fdd7b
...
...
@@ -71,3 +71,57 @@
</div>
{%
endmacro
%}
{%
macro
display_message
(
m
,
user
,
unread
=
False
)
%}
{%
if
user.can_view
(
m
)
%}
<div
id=
"msg_
{{
m.id
}}
"
class=
"message
{%
if
unread
%}
unread
{%
endif
%}
"
>
<div
class=
"msg_author
{%
if
m.deleted
%}
deleted
{%
endif
%}
"
>
{%
if
m.author.avatar_pict
%}
<img
src=
"
{{
m.author.avatar_pict.get_download_url
()
}}
"
alt=
"
{%
trans
%}
Profile
{%
endtrans
%}
"
id=
"picture"
/>
{%
else
%}
<img
src=
"
{{
static
(
'core/img/unknown.jpg'
)
}}
"
alt=
"
{%
trans
%}
Profile
{%
endtrans
%}
"
id=
"picture"
/>
{%
endif
%}
<br/>
<strong><a
href=
"
{{
m.author.get_absolute_url
()
}}
"
>
{{
m.author.get_short_name
()
}}
</a></strong>
</div>
<div
class=
"msg_content
{%
if
m.deleted
%}
deleted
{%
endif
%}
"
{%
if
m.id
==
first_unread_message_id
%}
id=
"first_unread"
{%
endif
%}
>
<div
style=
"display: inline-block; width: 74%;"
>
{%
if
m.title
%}
<h5>
{{
m.title
}}
</h5>
{%
endif
%}
</div>
<div
style=
"display: inline-block; width: 25%;"
>
<span><a
href=
"
{{
url
(
'forum:new_message'
,
topic_id
=
m.topic.id
)
}}
?quote_id=
{{
m.id
}}
"
>
{%
trans
%}
Reply as quote
{%
endtrans
%}
</a></span>
{%
if
user.can_edit
(
m
)
%}
<span>
<a
href=
"
{{
url
(
'forum:edit_message'
,
message_id
=
m.id
)
}}
"
>
{%
trans
%}
Edit
{%
endtrans
%}
</a></span>
{%
endif
%}
{%
if
m.can_be_moderated_by
(
user
)
%}
{%
if
m.deleted
%}
<span>
<a
href=
"
{{
url
(
'forum:undelete_message'
,
message_id
=
m.id
)
}}
"
>
{%
trans
%}
Undelete
{%
endtrans
%}
</a></span>
{%
else
%}
<span>
<a
href=
"
{{
url
(
'forum:delete_message'
,
message_id
=
m.id
)
}}
"
>
{%
trans
%}
Delete
{%
endtrans
%}
</a></span>
{%
endif
%}
{%
endif
%}
<br/>
<span>
{{
m.date
|
localtime
|
date
(
DATETIME_FORMAT
)
}}
{{
m.date
|
localtime
|
time
(
DATETIME_FORMAT
)
}}
</span>
</div>
<hr>
<div>
{{
m.message
|
markdown
}}
</div>
{%
if
m.can_be_moderated_by
(
user
)
%}
<ul
class=
"msg_meta"
>
{%
for
meta
in
m.metas.select_related
(
'user'
)
.
order_by
(
'id'
)
%}
<li
style=
"background:
{%
if
m.author
==
meta.user
%}
#bfffbf
{%
else
%}
#ffffbf
{%
endif
%}
"
>
{{
meta.get_action_display
()
}}
{{
meta.user.get_display_name
()
}}
{%
trans
%}
at
{%
endtrans
%}{{
meta.date
|
localtime
|
time
(
DATETIME_FORMAT
)
}}
{%
trans
%}
the
{%
endtrans
%}{{
meta.date
|
localtime
|
date
(
DATETIME_FORMAT
)
}}
</li>
{%
endfor
%}
</ul>
{%
endif
%}
</div>
</div>
{{
m.mark_as_read
(
user
)
or
""
}}
{%
endif
%}
{%
endmacro
%}
forum/templates/forum/reply.jinja
0 → 100644
View file @
777fdd7b
{%
extends
"core/base.jinja"
%}
{%
from
'forum/macros.jinja'
import
display_message
%}
{%
block
title
%}
{%
trans
%}
Reply
{%
endtrans
%}
{%
endblock
%}
{%
block
content
%}
<p>
<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
%}
>
<a
href=
"
{{
topic.forum.get_absolute_url
()
}}
"
>
{{
topic.forum
}}
</a>
>
<a
href=
"
{{
topic.get_absolute_url
()
}}
"
>
{{
topic
}}
</a>
</p>
<h3>
{{
topic.title
}}
</h3>
<h4>
{%
trans
%}
Reply
{%
endtrans
%}
</h4>
<form
action=
""
method=
"post"
enctype=
"multipart/form-data"
>
{%
csrf_token
%}
{{
form.as_p
()
}}
<p><input
type=
"submit"
value=
"
{%
trans
%}
Save
{%
endtrans
%}
"
/></p>
</form>
<hr>
{%
for
m
in
topic.messages.select_related
(
'author__avatar_pict'
)
.
order_by
(
'-id'
)
%}
{{
display_message
(
m
,
user
)
}}
{%
endfor
%}
{%
endblock
%}
forum/templates/forum/topic.jinja
View file @
777fdd7b
{%
extends
"core/base.jinja"
%}
{%
from
'core/macros.jinja'
import
user_profile_link
%}
{%
from
'forum/macros.jinja'
import
display_message
%}
{%
block
title
%}
{{
topic
}}
...
...
@@ -35,66 +36,17 @@
</p>
<h3>
{{
topic.title
}}
</h3>
<p>
{{
topic.description
}}
</p>
<p><a
href=
"
{{
url
(
'forum:new_message'
,
topic_id
=
topic.id
)
}}
"
>
Reply
</a></p>
<p><a
href=
"
{{
url
(
'forum:new_message'
,
topic_id
=
topic.id
)
}}
"
>
{%
trans
%}
Reply
{%
endtrans
%}
</a></p>
{%
for
m
in
topic.messages.select_related
(
'author__avatar_pict'
)
.
all
()
%}
{%
if
user.can_view
(
m
)
%}
{%
if
m.id
>=
first_unread_message_id
%}
<div
id=
"msg_
{{
m.id
}}
"
class=
"message unread"
>
{%
else
%}
<div
id=
"msg_
{{
m.id
}}
"
class=
"message"
>
{%
endif
%}
<div
class=
"msg_author
{%
if
m.deleted
%}
deleted
{%
endif
%}
"
>
{%
if
m.author.avatar_pict
%}
<img
src=
"
{{
m.author.avatar_pict.get_download_url
()
}}
"
alt=
"
{%
trans
%}
Profile
{%
endtrans
%}
"
id=
"picture"
/>
{%
else
%}
<img
src=
"
{{
static
(
'core/img/unknown.jpg'
)
}}
"
alt=
"
{%
trans
%}
Profile
{%
endtrans
%}
"
id=
"picture"
/>
{%
endif
%}
<br/>
<strong><a
href=
"
{{
m.author.get_absolute_url
()
}}
"
>
{{
m.author.get_short_name
()
}}
</a></strong>
</div>
<div
class=
"msg_content
{%
if
m.deleted
%}
deleted
{%
endif
%}
"
{%
if
m.id
==
first_unread_message_id
%}
id=
"first_unread"
{%
endif
%}
>
<div
style=
"display: inline-block; width: 74%;"
>
{%
if
m.title
%}
<h5>
{{
m.title
}}
</h5>
{%
endif
%}
</div>
<div
style=
"display: inline-block; width: 25%;"
>
<span><a
href=
"
{{
url
(
'forum:new_message'
,
topic_id
=
topic.id
)
}}
?quote_id=
{{
m.id
}}
"
>
{%
trans
%}
Reply as quote
{%
endtrans
%}
</a></span>
{%
if
user.can_edit
(
m
)
%}
<span>
<a
href=
"
{{
url
(
'forum:edit_message'
,
message_id
=
m.id
)
}}
"
>
{%
trans
%}
Edit
{%
endtrans
%}
</a></span>
{%
endif
%}
{%
if
m.can_be_moderated_by
(
user
)
%}
{%
if
m.deleted
%}
<span>
<a
href=
"
{{
url
(
'forum:undelete_message'
,
message_id
=
m.id
)
}}
"
>
{%
trans
%}
Undelete
{%
endtrans
%}
</a></span>
{%
else
%}
<span>
<a
href=
"
{{
url
(
'forum:delete_message'
,
message_id
=
m.id
)
}}
"
>
{%
trans
%}
Delete
{%
endtrans
%}
</a></span>
{%
endif
%}
{%
endif
%}
<br/>
<span>
{{
m.date
|
localtime
|
date
(
DATETIME_FORMAT
)
}}
{{
m.date
|
localtime
|
time
(
DATETIME_FORMAT
)
}}
</span>
</div>
<hr>
<div>
{{
m.message
|
markdown
}}
</div>
{%
if
m.can_be_moderated_by
(
user
)
%}
<ul
class=
"msg_meta"
>
{%
for
meta
in
m.metas.select_related
(
'user'
)
.
order_by
(
'id'
)
%}
<li
style=
"background:
{%
if
m.author
==
meta.user
%}
#bfffbf
{%
else
%}
#ffffbf
{%
endif
%}
"
>
{{
meta.get_action_display
()
}}
{{
meta.user.get_display_name
()
}}
{%
trans
%}
at
{%
endtrans
%}{{
meta.date
|
localtime
|
time
(
DATETIME_FORMAT
)
}}
{%
trans
%}
the
{%
endtrans
%}{{
meta.date
|
localtime
|
date
(
DATETIME_FORMAT
)
}}
</li>
{%
endfor
%}
</ul>
{%
endif
%}
</div>
</div>
{{
m.mark_as_read
(
user
)
or
""
}}
{%
endif
%}
{%
if
m.id
>=
first_unread_message_id
%}
{{
display_message
(
m
,
user
,
True
)
}}
{%
else
%}
{{
display_message
(
m
,
user
,
False
)
}}
{%
endif
%}
{%
endfor
%}
<p><a
href=
"
{{
url
(
'forum:new_message'
,
topic_id
=
topic.id
)
}}
"
>
Reply
</a></p>
<p><a
href=
"
{{
url
(
'forum:new_message'
,
topic_id
=
topic.id
)
}}
"
>
{%
trans
%}
Reply
{%
endtrans
%}
</a></p>
{%
endblock
%}
...
...
forum/views.py
View file @
777fdd7b
...
...
@@ -134,8 +134,8 @@ class ForumTopicDetailView(CanViewMixin, DetailView):
def
get_context_data
(
self
,
**
kwargs
):
kwargs
=
super
(
ForumTopicDetailView
,
self
).
get_context_data
(
**
kwargs
)
msg
=
self
.
object
.
messages
.
exclude
(
readers
=
self
.
request
.
user
).
filter
(
date__gte
=
self
.
request
.
user
.
forum_infos
.
last_read_date
).
order_by
(
'id'
).
first
()
try
:
msg
=
self
.
object
.
messages
.
exclude
(
readers
=
self
.
request
.
user
).
filter
(
date__gte
=
self
.
request
.
user
.
forum_infos
.
last_read_date
).
order_by
(
'id'
).
first
()
kwargs
[
'first_unread_message_id'
]
=
msg
.
id
except
:
kwargs
[
'first_unread_message_id'
]
=
float
(
"inf"
)
...
...
@@ -176,7 +176,7 @@ class ForumMessageUndeleteView(SingleObjectMixin, RedirectView):
class
ForumMessageCreateView
(
CanCreateMixin
,
CreateView
):
model
=
ForumMessage
fields
=
[
'title'
,
'message'
]
template_name
=
"
c
or
e/create
.jinja"
template_name
=
"
f
or
um/reply
.jinja"
def
dispatch
(
self
,
request
,
*
args
,
**
kwargs
):
self
.
topic
=
get_object_or_404
(
ForumTopic
,
id
=
self
.
kwargs
[
'topic_id'
])
...
...
@@ -202,4 +202,8 @@ class ForumMessageCreateView(CanCreateMixin, CreateView):
form
.
instance
.
author
=
self
.
request
.
user
return
super
(
ForumMessageCreateView
,
self
).
form_valid
(
form
)
def
get_context_data
(
self
,
**
kwargs
):
kwargs
=
super
(
ForumMessageCreateView
,
self
).
get_context_data
(
**
kwargs
)
kwargs
[
'topic'
]
=
self
.
topic
return
kwargs
locale/fr/LC_MESSAGES/django.po
View file @
777fdd7b
...
...
@@ -6,7 +6,7 @@
msgid
""
msgstr
""
"Report-Msgid-Bugs-To:
\n
"
"POT-Creation-Date: 2017-02-24
04
:3
3
+0100
\n
"
"POT-Creation-Date: 2017-02-24
16
:3
0
+0100
\n
"
"PO-Revision-Date: 2016-07-18
\n
"
"Last-Translator: Skia <skia@libskia.so>
\n
"
"Language-Team: AE info <ae.info@utbm.fr>
\n
"
...
...
@@ -125,10 +125,10 @@ msgstr "numéro"
msgid
"journal"
msgstr
"classeur"
#: accounting/models.py:194 core/models.py:546 core/models.py:
902
#: core/models.py:9
42
counter/models.py:242 counter/models.py:290
#: accounting/models.py:194 core/models.py:546 core/models.py:
899
#: core/models.py:9
39
counter/models.py:242 counter/models.py:290
#: counter/models.py:416 eboutic/models.py:15 eboutic/models.py:48
#: forum/models.py:155 forum/models.py:20
5
#: forum/models.py:155 forum/models.py:20
7
msgid
"date"
msgstr
"date"
...
...
@@ -1089,7 +1089,7 @@ msgstr "résumé"
msgid
"content"
msgstr
"contenu de la nouvelle"
#: com/models.py:36 core/models.py:9
41
launderette/models.py:60
#: com/models.py:36 core/models.py:9
38
launderette/models.py:60
#: launderette/models.py:85 launderette/models.py:121
msgid
"type"
msgstr
"type"
...
...
@@ -1171,6 +1171,7 @@ msgstr "Type"
#: com/templates/com/news_admin_list.jinja:15
#: com/templates/com/news_admin_list.jinja:49
#: com/templates/com/weekmail.jinja:18 com/templates/com/weekmail.jinja:41
#: forum/templates/forum/forum.jinja:26 forum/templates/forum/forum.jinja:44
msgid
"Title"
msgstr
"Titre"
...
...
@@ -1182,6 +1183,7 @@ msgstr "Résumé"
#: com/templates/com/news_admin_list.jinja:18
#: com/templates/com/news_admin_list.jinja:52
#: com/templates/com/weekmail.jinja:16 com/templates/com/weekmail.jinja:39
#: forum/templates/forum/forum.jinja:48
msgid
"Author"
msgstr
"Auteur"
...
...
@@ -1614,7 +1616,7 @@ msgstr "Un utilisateur de ce nom d'utilisateur existe déjà"
#: core/templates/core/user_detail.jinja:16
#: core/templates/core/user_edit.jinja:17
#: election/templates/election/election_detail.jinja:316
#: forum/templates/forum/topic.jinja:4
8
forum/templates/forum/topic.jinja:5
0
#: forum/templates/forum/topic.jinja:4
9
forum/templates/forum/topic.jinja:5
1
msgid
"Profile"
msgstr
"Profil"
...
...
@@ -1725,8 +1727,7 @@ msgid ""
"Enter a valid page name. This value may contain only letters, numbers and ./"
"+/-/_ characters."
msgstr
""
"Entrez un nom de page correct. Uniquement des lettres, numéros, et ./"
"+/-/_"
"Entrez un nom de page correct. Uniquement des lettres, numéros, et ./+/-/_"
#: core/models.py:747
msgid
"page name"
...
...
@@ -1752,27 +1753,27 @@ msgstr "Une page de ce nom existe déjà"
msgid
"Loop in page tree"
msgstr
"Boucle dans l'arborescence des pages"
#: core/models.py:89
9
#: core/models.py:89
6
msgid
"revision"
msgstr
"révision"
#: core/models.py:
900
#: core/models.py:
897
msgid
"page title"
msgstr
"titre de la page"
#: core/models.py:
901
#: core/models.py:
898
msgid
"page content"
msgstr
"contenu de la page"
#: core/models.py:93
9
#: core/models.py:93
6
msgid
"url"
msgstr
"url"
#: core/models.py:9
40
#: core/models.py:9
37
msgid
"param"
msgstr
"param"
#: core/models.py:94
3
#: core/models.py:94
0
msgid
"viewed"
msgstr
"vue"
...
...
@@ -3342,7 +3343,7 @@ msgstr "Les votes ouvriront "
#: election/templates/election/election_list.jinja:34
#: election/templates/election/election_list.jinja:39
#: election/templates/election/election_list.jinja:42
#: forum/templates/forum/topic.jinja:8
6
#: forum/templates/forum/topic.jinja:8
7
msgid
" at "
msgstr
" à "
...
...
@@ -3457,23 +3458,23 @@ msgstr "message"
msgid
"readers"
msgstr
"lecteurs"
#: forum/models.py:19
7
#: forum/models.py:19
9
msgid
"Message edited by"
msgstr
"Message édité par"
#: forum/models.py:
198
#: forum/models.py:
200
msgid
"Message deleted by"
msgstr
"Message supprimé par"
#: forum/models.py:
199
#: forum/models.py:
201
msgid
"Message undeleted by"
msgstr
"Message restauré par"
#: forum/models.py:20
6
#: forum/models.py:20
8
msgid
"action"
msgstr
"action"
#: forum/models.py:21
5
#: forum/models.py:21
7
msgid
"last read date"
msgstr
"dernière date de lecture"
...
...
@@ -3485,6 +3486,18 @@ msgstr "Nouveau forum"
msgid
"New topic"
msgstr
"Nouveau sujet"
#: forum/templates/forum/forum.jinja:30
msgid
"Topics"
msgstr
"Sujets"
#: forum/templates/forum/forum.jinja:33 forum/templates/forum/forum.jinja:54
msgid
"Last message"
msgstr
"Dernier message"
#: forum/templates/forum/forum.jinja:51
msgid
"Messages"
msgstr
"Messages"
#: forum/templates/forum/last_unread.jinja:5
#: forum/templates/forum/last_unread.jinja:13
msgid
"Last unread messages"
...
...
@@ -3498,6 +3511,10 @@ msgstr "Rafraîchir"
msgid
"View last unread messages"
msgstr
"Voir les derniers messages non lus"
#: forum/templates/forum/topic.jinja:38 forum/templates/forum/topic.jinja:97
msgid
"Reply"
msgstr
"Répondre"
#: forum/templates/forum/topic.jinja:64
msgid
"Reply as quote"
msgstr
"Répondre en citant"
...
...
@@ -3506,15 +3523,15 @@ msgstr "Répondre en citant"
msgid
"Undelete"
msgstr
"Restaurer"
#: forum/templates/forum/topic.jinja:8
7
#: forum/templates/forum/topic.jinja:8
8
msgid
" the "
msgstr
" le "
#: forum/views.py:6
5
#: forum/views.py:6
7
msgid
"Apply rights and club owner recursively"
msgstr
"Appliquer les droits et le club propriétaire récursivement"
#: forum/views.py:1
83
#: forum/views.py:1
91
#, python-format
msgid
"%(author)s said"
msgstr
"Citation de %(author)s"
...
...
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