Commits

cur...@tinbrain.net  committed 89f182b

Annotate threads in forum detail view with most recent post dates and post count
Set more reasonable template names

  • Participants
  • Parent commits 83d897e

Comments (0)

Files changed (1)

File gnocchi_forum/views.py

     forum = get_object_or_404(models.Forum, slug=forum)
     # permssion check?
     return object_list(request,
-        queryset = forum.thread_set.all(),
+        queryset = forum.thread_set.annotate(
+            most_recent_post=models.Max('post__created'),
+            post_count=models.Count('post')
+        ).all(),
+        template_name='forum/forum_detail.html',
         extra_context = {
             'forum': forum,
         }
     thread = get_object_or_404(models.Thread, slug=thread, forum__slug=forum)
     return object_list(request,
         queryset = thread.post_set.all(),
+        template_name='forum/thread_detail.html',
         extra_context = {
             'thread': thread,
         }