diff --git a/core/static/core/style.css b/core/static/core/style.css
index 1818bf0c..5a7235ed 100644
--- a/core/static/core/style.css
+++ b/core/static/core/style.css
@@ -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 {
diff --git a/forum/models.py b/forum/models.py
index d19f7d91..d22425f9 100644
--- a/forum/models.py
+++ b/forum/models.py
@@ -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())
diff --git a/forum/templates/forum/forum.jinja b/forum/templates/forum/forum.jinja
index edd85de8..9cb87de7 100644
--- a/forum/templates/forum/forum.jinja
+++ b/forum/templates/forum/forum.jinja
@@ -23,14 +23,14 @@
{% if forum.children.exists() %}
- Title
+ {% trans %}Title{% endtrans %}
- Topics
+ {% trans %}Topics{% endtrans %}
- Last message
+ {% trans %}Last message{% endtrans %}
@@ -41,17 +41,17 @@
{% if topics %}
- Title
+ {% trans %}Title{% endtrans %}
- Author
+ {% trans %}Author{% endtrans %}
- Messages
+ {% trans %}Messages{% endtrans %}
- Last message
+ {% trans %}Last message{% endtrans %}
diff --git a/forum/templates/forum/macros.jinja b/forum/templates/forum/macros.jinja
index 3db80bdb..f3446041 100644
--- a/forum/templates/forum/macros.jinja
+++ b/forum/templates/forum/macros.jinja
@@ -71,3 +71,57 @@
{% endmacro %}
+{% macro display_message(m, user, unread=False) %}
+{% if user.can_view(m) %}
+
+
+
+
+ {% if m.title %}
+
{{ m.title }}
+ {% endif %}
+
+
+
+
+ {{ m.message|markdown }}
+
+ {% if m.can_be_moderated_by(user) %}
+
+ {% endif %}
+
+
+{{ m.mark_as_read(user) or "" }}
+{% endif %}
+{% endmacro %}
+
diff --git a/forum/templates/forum/reply.jinja b/forum/templates/forum/reply.jinja
new file mode 100644
index 00000000..206711db
--- /dev/null
+++ b/forum/templates/forum/reply.jinja
@@ -0,0 +1,35 @@
+{% extends "core/base.jinja" %}
+{% from 'forum/macros.jinja' import display_message %}
+
+{% block title %}
+{% trans %}Reply{% endtrans %}
+{% endblock %}
+
+{% block content %}
+
+{% trans %}Forum{% endtrans %}
+{% for f in topic.forum.get_parent_list() %}
+> {{ f }}
+{% endfor %}
+> {{ topic.forum }}
+> {{ topic }}
+
+{{ topic.title }}
+{% trans %}Reply{% endtrans %}
+
+
+
+
+{% for m in topic.messages.select_related('author__avatar_pict').order_by('-id') %}
+ {{ display_message(m, user) }}
+{% endfor %}
+
+{% endblock %}
+
+
+
+
diff --git a/forum/templates/forum/topic.jinja b/forum/templates/forum/topic.jinja
index cec0514c..6e471d68 100644
--- a/forum/templates/forum/topic.jinja
+++ b/forum/templates/forum/topic.jinja
@@ -1,5 +1,6 @@
{% 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 @@
{{ topic.title }}
{{ topic.description }}
- Reply
+ {% trans %}Reply{% endtrans %}
{% for m in topic.messages.select_related('author__avatar_pict').all() %}
- {% if user.can_view(m) %}
- {% if m.id >= first_unread_message_id %}
-
- {% else %}
-
- {% endif %}
-
-
-
- {% if m.title %}
-
{{ m.title }}
- {% endif %}
-
-
-
-
- {{ m.message|markdown }}
-
- {% if m.can_be_moderated_by(user) %}
-
- {% endif %}
-
-
- {{ 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 %}
-
Reply
+
+
{% trans %}Reply{% endtrans %}
{% endblock %}
diff --git a/forum/views.py b/forum/views.py
index b5ac90c8..6e46658f 100644
--- a/forum/views.py
+++ b/forum/views.py
@@ -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 = "core/create.jinja"
+ template_name = "forum/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
diff --git a/locale/fr/LC_MESSAGES/django.po b/locale/fr/LC_MESSAGES/django.po
index 016e8af9..35978e2d 100644
--- a/locale/fr/LC_MESSAGES/django.po
+++ b/locale/fr/LC_MESSAGES/django.po
@@ -6,7 +6,7 @@
msgid ""
msgstr ""
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2017-02-24 04:33+0100\n"
+"POT-Creation-Date: 2017-02-24 16:30+0100\n"
"PO-Revision-Date: 2016-07-18\n"
"Last-Translator: Skia
\n"
"Language-Team: AE info \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:942 counter/models.py:242 counter/models.py:290
+#: accounting/models.py:194 core/models.py:546 core/models.py:899
+#: core/models.py:939 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:205
+#: forum/models.py:155 forum/models.py:207
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:941 launderette/models.py:60
+#: com/models.py:36 core/models.py:938 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:48 forum/templates/forum/topic.jinja:50
+#: forum/templates/forum/topic.jinja:49 forum/templates/forum/topic.jinja:51
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:899
+#: core/models.py:896
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:939
+#: core/models.py:936
msgid "url"
msgstr "url"
-#: core/models.py:940
+#: core/models.py:937
msgid "param"
msgstr "param"
-#: core/models.py:943
+#: core/models.py:940
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:86
+#: forum/templates/forum/topic.jinja:87
msgid " at "
msgstr " à "
@@ -3457,23 +3458,23 @@ msgstr "message"
msgid "readers"
msgstr "lecteurs"
-#: forum/models.py:197
+#: forum/models.py:199
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:206
+#: forum/models.py:208
msgid "action"
msgstr "action"
-#: forum/models.py:215
+#: forum/models.py:217
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:87
+#: forum/templates/forum/topic.jinja:88
msgid " the "
msgstr " le "
-#: forum/views.py:65
+#: forum/views.py:67
msgid "Apply rights and club owner recursively"
msgstr "Appliquer les droits et le club propriétaire récursivement"
-#: forum/views.py:183
+#: forum/views.py:191
#, python-format
msgid "%(author)s said"
msgstr "Citation de %(author)s"