Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
get_last_post et get_last_message tiennent compte des postes masqués
  • Loading branch information
Rowin committed Mar 2, 2021
1 parent 6b84ea1 commit 8ea40c1
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions zds/forum/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def get_last_message(self):
:return: the last message on the forum, if there are any.
"""
try:
return Post.objects.filter(topic__forum=self).order_by("-pubdate").all()[0]
return Post.objects.filter(topic__forum=self, is_visible=True).order_by("-pubdate").all()[0]
except IndexError:
return None

Expand Down Expand Up @@ -257,7 +257,10 @@ def get_last_post(self):
"""
:return: the last post in the thread.
"""
return self.last_message
try:
return self.post_set.filter(is_visible=True).latest("pubdate")
except Post.DoesNotExist:
return None

def get_last_answer(self):
"""
Expand Down

0 comments on commit 8ea40c1

Please sign in to comment.