--- 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
--- 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 []