Many updates to handle non public comments properly

This commit is contained in:
Patrick Gerken
2013-03-28 14:28:22 +01:00
parent 6320048b37
commit 05f0e7e4d8
8 changed files with 87 additions and 13 deletions
+17 -4
View File
@@ -95,15 +95,28 @@ class Conversation(Traversable, Persistent, Explicit):
@property
def last_comment_date(self):
try:
return self._comments[self._comments.maxKey()].creation_date
except (ValueError, KeyError, AttributeError,):
return None
# self._comments is an Instance of a btree. The keys
# are always ordered
comment_keys = self._comments.keys()
for comment_key in reversed(comment_keys):
comment = self._comments[comment_key]
if user_nobody.has_permission('View', comment):
return comment.creation_date
return None
@property
def commentators(self):
return self._commentators
@property
def public_commentators(self):
retval = set()
for comment in self._comments.values():
if not user_nobody.has_permission('View', comment):
continue
retval.add(comment.author_username)
return tuple(retval)
def objectIds(self):
return self._comments.keys()