# HG changeset patch # User raph # Date 1259837750 -3600 # Node ID 036705244cab518c4ee4ce7b3a7caf9ddd415a52 # Parent 6ed2af5ab085f621d32aa6ea2cf9f4435d2d5807 FIX: comment visibility takes ownership into account diff -r 6ed2af5ab085 -r 036705244cab src/cm/models.py --- a/src/cm/models.py Thu Dec 03 11:38:28 2009 +0100 +++ b/src/cm/models.py Thu Dec 03 11:55:50 2009 +0100 @@ -285,18 +285,17 @@ def is_reply(self): return self.reply_to != None - def is_thread_full_visible(self): - cur_comment = self - if not cur_comment.state == 'approved': - return False - - while cur_comment.reply_to != None: - cur_comment = cur_comment.reply_to - if not cur_comment.state == 'approved': - return False - - return True - + def is_thread_full_visible(self, own_user=None): + """ + own_user: comment belonging to this user are also visible + """ + if self.state == 'approved' or (own_user and self.user == own_user): + if self.reply_to==None: + return True + else: + return self.reply_to.is_thread_full_visible(own_user) + return False + def top_comment(self): if self.reply_to == None : return self diff -r 6ed2af5ab085 -r 036705244cab src/cm/security.py --- a/src/cm/security.py Thu Dec 03 11:38:28 2009 +0100 +++ b/src/cm/security.py Thu Dec 03 11:55:50 2009 +0100 @@ -153,7 +153,7 @@ elif user and has_perm(request, 'can_view_comment_own', text=text): visible_comments = comments.filter(user=user).order_by(*order_by) # filter comments with a non visible (i.e. moderated) comment in the above thread - comments_thread_viewable = [c for c in visible_comments if c.is_thread_full_visible()] + comments_thread_viewable = [c for c in visible_comments if c.is_thread_full_visible(own_user=user)] return comments_thread_viewable else: return []