Revert "Merge pull request #38 from delib/evilbungle-comment-acquisition"

This reverts commit e18598e316, reversing
changes made to fd6ac0788b.

This pull request introduces two test failures. See http://jenkins.plone.org/job/plone-5.0-python-2.7/lastCompletedBuild/testReport/ for details.
This commit is contained in:
Timo Stollenwerk
2014-05-13 07:07:37 +02:00
parent e18598e316
commit 2b18d5a2e4
8 changed files with 6 additions and 405 deletions
+6 -12
View File
@@ -50,14 +50,8 @@ from plone.app.discussion.comment import Comment
from AccessControl.SpecialUsers import nobody as user_nobody
from ComputedAttribute import ComputedAttribute
ANNOTATION_KEY = 'plone.app.discussion:conversation'
def computed_attribute_decorator(level=0):
def computed_attribute_wrapper(func):
return ComputedAttribute(func, level)
return computed_attribute_wrapper
class Conversation(Traversable, Persistent, Explicit):
"""A conversation is a container for all comments on a content object.
@@ -93,21 +87,21 @@ class Conversation(Traversable, Persistent, Explicit):
parent = aq_inner(self.__parent__)
return parent.restrictedTraverse('@@conversation_view').enabled()
@computed_attribute_decorator(level=1)
@property
def total_comments(self):
public_comments = [
x for x in self.values()
x for x in self._comments.values()
if user_nobody.has_permission('View', x)
]
return len(public_comments)
@computed_attribute_decorator(level=1)
@property
def last_comment_date(self):
# 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[comment_key]
comment = self._comments[comment_key]
if user_nobody.has_permission('View', comment):
return comment.creation_date
return None
@@ -116,10 +110,10 @@ class Conversation(Traversable, Persistent, Explicit):
def commentators(self):
return self._commentators
@computed_attribute_decorator(level=1)
@property
def public_commentators(self):
retval = set()
for comment in self.values():
for comment in self._comments.values():
if not user_nobody.has_permission('View', comment):
continue
retval.add(comment.author_username)