From 29452c7a7e30a630bc5a05f5babd73d4ad416dd9 Mon Sep 17 00:00:00 2001 From: "J.-S. Caux" <J.S.Caux@uva.nl> Date: Wed, 24 Mar 2021 06:25:40 +0100 Subject: [PATCH] Dig into posts hierarchy in forum_detail --- forums/models.py | 8 ++++++++ forums/templates/forums/forum_detail.html | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/forums/models.py b/forums/models.py index 7086fee7b..d94cc5edc 100644 --- a/forums/models.py +++ b/forums/models.py @@ -94,6 +94,14 @@ class Forum(models.Model): except: return None + @property + def posts_all(self): + """ + Return all posts in the hierarchy. + """ + posts_id_list = self.posts_hierarchy_id_list() + return Post.objects.filter(id__in=posts_id_list) + class Meeting(Forum): """ diff --git a/forums/templates/forums/forum_detail.html b/forums/templates/forums/forum_detail.html index b0e6f3eb0..95fbbf234 100644 --- a/forums/templates/forums/forum_detail.html +++ b/forums/templates/forums/forum_detail.html @@ -124,7 +124,7 @@ <div class="card-body collapse" id="recentPostsLinks"> <h3>(most recent first)</h3> <ul> - {% for post in forum.posts.reverse %} + {% for post in forum.posts_all.reverse %} <li> <a href="{{ post.get_absolute_url }}">{{ post.subject }}</a> posted by {{ post.posted_by.first_name }} {{ post.posted_by.last_name }} on {{ post.posted_on|date:"Y-m-d H:m" }} {% if post.parent and not post.motion %} -- GitLab