From 4be4c03c49f478e7339d59b008fc21ba52576e9e Mon Sep 17 00:00:00 2001 From: Alan Hoey Date: Thu, 21 Nov 2013 18:13:31 +0000 Subject: [PATCH] Fix total comments index --- plone/app/discussion/conversation.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/plone/app/discussion/conversation.py b/plone/app/discussion/conversation.py index ba27c0f..16a3cec 100644 --- a/plone/app/discussion/conversation.py +++ b/plone/app/discussion/conversation.py @@ -50,8 +50,14 @@ 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. @@ -87,10 +93,10 @@ class Conversation(Traversable, Persistent, Explicit): parent = aq_inner(self.__parent__) return parent.restrictedTraverse('@@conversation_view').enabled() - @property + @computed_attribute_decorator(level=1) def total_comments(self): public_comments = [ - x for x in self._comments.values() + x for x in self.values() if user_nobody.has_permission('View', x) ] return len(public_comments)