Skip to content
Snippets Groups Projects
Commit 69db5f062634 authored by Sylvain Thénault's avatar Sylvain Thénault
Browse files

make subcomments_count usable as a function taking any commentable object as argument

parent 74eb3c3bd18f
No related branches found
No related tags found
No related merge requests found
......@@ -14,6 +14,11 @@
from cubicweb.selectors import implements
from cubicweb.entities import AnyEntity, fetch_config
def subcomments_count(commentable):
return sum([len(commentable.reverse_comments)]
+ [subcomments_count(c) for c in commentable.reverse_comments])
class Comment(TreeMixIn, AnyEntity):
"""customized class for Comment entities"""
__regid__ = 'Comment'
......@@ -34,10 +39,9 @@
"""
return self.root().rest_path(), {}
def subcomments_count(self):
return sum([len(self.reverse_comments)]
+ [c.subcomments_count() for c in self.reverse_comments])
subcomments_count = subcomments_count
# some views potentially needed on web *and* server side (for notification)
# so put them here
......@@ -40,8 +44,7 @@
# some views potentially needed on web *and* server side (for notification)
# so put them here
class CommentFullTextView(EntityView):
__regid__ = 'fulltext'
__select__ = implements('Comment')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment