diff --git a/core/static/core/style.css b/core/static/core/style.css index 293a12f7..1818bf0c 100644 --- a/core/static/core/style.css +++ b/core/static/core/style.css @@ -414,23 +414,43 @@ textarea { .message { padding: 2px; margin: 2px; - background: skyblue; -} -.unread { - background: #e6ddad; + background: #eff7ff; } .message h5 { font-size: 100%; } +.unread { + background: #d8e7f3; +} +.msg_author.deleted { + background: #ffcfcf; +} +.msg_content.deleted { + background: #ffefef; +} +.msg_content { + display: inline-block; + width: 80%; + vertical-align: top; +} .msg_author { display: inline-block; width: 19%; text-align: center; + background: #d8e7f3; } .msg_author img { - max-width: 80%; + max-width: 70%; margin: 0px auto; } +.msg_meta { + font-size: small; + list-style-type: none; +} +.msg_meta li { + padding: 2px; + margin: 2px; +} /*------------------------------SAS------------------------------------*/ .album { display: inline-block; diff --git a/forum/models.py b/forum/models.py index 8e29b98f..d19f7d91 100644 --- a/forum/models.py +++ b/forum/models.py @@ -126,7 +126,7 @@ class ForumTopic(models.Model): ordering = ['-id'] # TODO: add date message ordering def is_owned_by(self, user): - return self.forum.is_owned_by(user) or user.id == self.author.id + return self.forum.is_owned_by(user) def can_be_edited_by(self, user): return user.can_edit(self.forum) @@ -169,10 +169,10 @@ class ForumMessage(models.Model): return user.can_edit(self.topic.forum) def can_be_viewed_by(self, user): - return user.can_view(self.topic) + return (not self.deleted and user.can_view(self.topic)) def can_be_moderated_by(self, user): - return self.topic.forum.is_owned_by(user) + return self.topic.forum.is_owned_by(user) or user.id == self.author.id def get_absolute_url(self): return self.topic.get_absolute_url() + "#msg_" + str(self.id) diff --git a/forum/templates/forum/forum.jinja b/forum/templates/forum/forum.jinja index a159f1e1..edd85de8 100644 --- a/forum/templates/forum/forum.jinja +++ b/forum/templates/forum/forum.jinja @@ -20,12 +20,45 @@ {% endif %} {% trans %}New topic{% endtrans %}

+ {% if forum.children.exists() %} +
+
+ Title +
+
+
+ Topics +
+
+ Last message +
+
+
{% for f in forum.children.all() %} {{ display_forum(f, user) }} {% endfor %} + {% endif %} + {% if topics %} +
+
+ Title +
+
+
+ Author +
+
+ Messages +
+
+ Last message +
+
+
{% for t in topics %} {{ display_topic(t, user) }} {% endfor %} + {% endif %} {% endblock %} diff --git a/forum/templates/forum/macros.jinja b/forum/templates/forum/macros.jinja index 8617ad60..3db80bdb 100644 --- a/forum/templates/forum/macros.jinja +++ b/forum/templates/forum/macros.jinja @@ -47,7 +47,7 @@
{{ topic.title }}

{{ topic.description }}

- {% if user.is_owner(topic) %} + {% if user.can_edit(topic) %}
{% trans %}Edit{% endtrans %}
diff --git a/forum/templates/forum/topic.jinja b/forum/templates/forum/topic.jinja index 126c1dcb..cec0514c 100644 --- a/forum/templates/forum/topic.jinja +++ b/forum/templates/forum/topic.jinja @@ -37,23 +37,23 @@

{{ topic.description }}

Reply

- {% for m in topic.messages.select_related('author__profile_pict').all() %} + {% 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.author.profile_pict %} - {% trans %}Profile{% endtrans %} +
+ {% if m.author.avatar_pict %} + {% trans %}Profile{% endtrans %} {% else %} {% trans %}Profile{% endtrans %} {% endif %}
- {{ user_profile_link(m.author) }} + {{ m.author.get_short_name() }}
-
+
{% if m.title %}
{{ m.title }}
@@ -73,24 +73,26 @@ {% endif %} {% endif %}
- {{ m.date|date(DATETIME_FORMAT) }} {{ m.date|time(DATETIME_FORMAT) }} + {{ m.date|localtime|date(DATETIME_FORMAT) }} {{ m.date|localtime|time(DATETIME_FORMAT) }}

{{ m.message|markdown }}
{% if m.can_be_moderated_by(user) %} -
    - {% for meta in m.metas.select_related('user').all() %} -
  • {{ meta.get_action_display() }} {{ meta.user.get_display_name() }} - {% trans %} at {% endtrans %}{{ meta.date|time(DATETIME_FORMAT) }} - {% trans %} the {% endtrans %}{{ meta.date|date(DATETIME_FORMAT)}}
  • +
      + {% for meta in m.metas.select_related('user').order_by('id') %} +
    • + {{ 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)}}
    • {% endfor %}
    {% endif %}
{{ m.mark_as_read(user) or "" }} + {% endif %} {% endfor %}

Reply

{% endblock %} diff --git a/forum/views.py b/forum/views.py index 7b504bfc..b5ac90c8 100644 --- a/forum/views.py +++ b/forum/views.py @@ -58,6 +58,8 @@ class ForumCreateView(CanCreateMixin, CreateView): parent = Forum.objects.filter(id=self.request.GET['parent']).first() init['parent'] = parent init['owner_club'] = parent.owner_club + init['edit_groups'] = parent.edit_groups.all() + init['view_groups'] = parent.view_groups.all() except: pass return init @@ -93,9 +95,15 @@ class ForumDetailView(CanViewMixin, DetailView): kwargs['topics'] = self.object.topics.annotate(models.Max('messages__date')).order_by('-messages__date__max') return kwargs +class TopicForm(forms.ModelForm): + class Meta: + model = ForumMessage + fields = ['title', 'message'] + title = forms.CharField(required=True) + class ForumTopicCreateView(CanCreateMixin, CreateView): model = ForumMessage - fields = ['title', 'message'] + form_class = TopicForm template_name = "core/create.jinja" def dispatch(self, request, *args, **kwargs):