From 624123929a7acf5856f03ccd4a9e3766258a2a54 Mon Sep 17 00:00:00 2001 From: Deimos Date: Thu, 3 Sep 2020 15:16:21 -0600 Subject: [PATCH] Exclude removed comments from "last comment" link The "last comment posted" link in the sidebar on a topic's comments page was still considering removed comments, so if the last comment in a topic was removed it would link to that one. That's not very useful for anyone, so this excludes removed comments the same way that deleted ones were already excluded. --- tildes/tildes/models/comment/comment_tree.py | 4 ++-- tildes/tildes/templates/topic.jinja2 | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tildes/tildes/models/comment/comment_tree.py b/tildes/tildes/models/comment/comment_tree.py index 107d84f..40be94d 100644 --- a/tildes/tildes/models/comment/comment_tree.py +++ b/tildes/tildes/models/comment/comment_tree.py @@ -181,9 +181,9 @@ class CommentTree: @property def most_recent_comment(self) -> Optional[Comment]: - """Return the most recent non-deleted Comment in the tree.""" + """Return the most recent Comment in the tree (excluding deleted/removed).""" for comment in reversed(self.comments): - if not comment.is_deleted: + if not (comment.is_deleted or comment.is_removed): return comment return None diff --git a/tildes/tildes/templates/topic.jinja2 b/tildes/tildes/templates/topic.jinja2 index 12d9158..4a06858 100644 --- a/tildes/tildes/templates/topic.jinja2 +++ b/tildes/tildes/templates/topic.jinja2 @@ -326,7 +326,7 @@
Last comment posted
- {{ adaptive_date_responsive(topic.last_activity_time) }} + {{ adaptive_date_responsive(comments.most_recent_comment.created_time) }}
{% else %}