diff --git a/forum/templates/forum/main.jinja b/forum/templates/forum/main.jinja
index 243cbb12..ccca49cb 100644
--- a/forum/templates/forum/main.jinja
+++ b/forum/templates/forum/main.jinja
@@ -7,9 +7,10 @@
{% endblock %}
{% block content %}
-
{% trans %}Forum{% endtrans %}
{% trans %}View last unread messages{% endtrans %}
@@ -19,14 +20,28 @@
{% trans %}New forum{% endtrans %}
{% endif %}
+
+
+ {% trans %}Title{% endtrans %}
+
+
+
+ {% trans %}Topics{% endtrans %}
+
+
+ {% trans %}Last message{% endtrans %}
+
+
+
{% for f in forum_list %}
-
- {{ display_forum(f, user) }}
+
+ {{ display_forum(f, user, True) }}
{% for c in f.children.all() %}
{{ display_forum(c, user) }}
{% endfor %}
{% endfor %}
+
{% endblock %}
diff --git a/forum/templates/forum/topic.jinja b/forum/templates/forum/topic.jinja
index 80c246b1..0e02b99e 100644
--- a/forum/templates/forum/topic.jinja
+++ b/forum/templates/forum/topic.jinja
@@ -35,6 +35,7 @@
>
{{ topic }}
{{ topic.title }}
+
{% endblock %}
diff --git a/forum/views.py b/forum/views.py
index 5ef4ff5b..87005b87 100644
--- a/forum/views.py
+++ b/forum/views.py
@@ -59,6 +59,7 @@ class ForumMarkAllAsRead(RedirectView):
class ForumLastUnread(ListView):
model = ForumTopic
template_name = "forum/last_unread.jinja"
+ paginate_by = settings.SITH_FORUM_PAGE_LENGTH / 2
def get_queryset(self):
l = ForumMessage.objects.exclude(readers=self.request.user).filter(
@@ -117,7 +118,16 @@ class ForumDetailView(CanViewMixin, DetailView):
def get_context_data(self, **kwargs):
kwargs = super(ForumDetailView, self).get_context_data(**kwargs)
- kwargs['topics'] = self.object.topics.annotate(models.Max('messages__date')).order_by('-messages__date__max')
+ qs = self.object.topics.order_by('-_last_message__date').select_related('_last_message')
+ paginator = Paginator(qs,
+ settings.SITH_FORUM_PAGE_LENGTH)
+ page = self.request.GET.get('topic_page')
+ try:
+ kwargs["topics"] = paginator.page(page)
+ except PageNotAnInteger:
+ kwargs["topics"] = paginator.page(1)
+ except EmptyPage:
+ kwargs["topics"] = paginator.page(paginator.num_pages)
return kwargs
class TopicForm(forms.ModelForm):
@@ -164,7 +174,7 @@ class ForumTopicDetailView(CanViewMixin, DetailView):
kwargs['first_unread_message_id'] = msg.id
except:
kwargs['first_unread_message_id'] = float("inf")
- paginator = Paginator(self.object.messages.select_related('author__avatar_pict').all(),
+ paginator = Paginator(self.object.messages.select_related('author__avatar_pict').order_by('date'),
settings.SITH_FORUM_PAGE_LENGTH)
page = self.request.GET.get('page')
try: