def comment_count(self, obj):
        """
        Returns the number of comments for the given object or False if
        comments are disabled.
        """

        if HAS_PAD:
            if IDiscussionLayer.providedBy(self.request):
                conversation = IConversation(obj)
                return conversation.enabled() and len(conversation)
        if self.context.portal_discussion.isDiscussionAllowedFor(obj):
            discussion = self.context.portal_discussion.getDiscussionFor(obj)
            return discussion.replyCount(obj)
        return False
    def comment_count(self, obj):
        """
        Returns the number of comments for the given object or False if
        comments are disabled.
        """

        if HAS_PAD:
            if IDiscussionLayer.providedBy(self.request):
                conversation = IConversation(obj)
                return conversation.enabled() and len(conversation)
        if self.context.portal_discussion.isDiscussionAllowedFor(obj):
            discussion = self.context.portal_discussion.getDiscussionFor(obj)
            return discussion.replyCount(obj)
        return False
Esempio n. 3
0
    def comment_count(self, obj):
        """
        Returns the number of comments for the given object or False if
        comments are disabled.
        """

        discussion_allowed = self.portal_discussion.isDiscussionAllowedFor(obj)
        if not HAS_PAD and not discussion_allowed:
            return False

        if not HAS_PAD and self.portal_discussion.isDiscussionAllowedFor(obj):
            discussion = self.portal_discussion.getDiscussionFor(obj)
            return discussion.replyCount(obj)

        # HAS_PAD == True
        if IDiscussionLayer.providedBy(self.request):
            conversation = IConversation(obj)
            if conversation.enabled():
                workflow = getToolByName(self.context, "portal_workflow")
                cvalues = conversation.values()
                return len([c for c in cvalues if workflow.getInfoFor(c, "review_state") == "published"])
Esempio n. 4
0
    def comment_count(self, obj):
        """
        Returns the number of comments for the given object or False if
        comments are disabled.
        """

        discussion_allowed = self.portal_discussion.isDiscussionAllowedFor(obj)
        if not HAS_PAD and not discussion_allowed:
            return False

        if not HAS_PAD and self.portal_discussion.isDiscussionAllowedFor(obj):
            discussion = self.portal_discussion.getDiscussionFor(obj)
            return discussion.replyCount(obj)

        #HAS_PAD == True
        if IDiscussionLayer.providedBy(self.request):
            conversation = IConversation(obj)
            if conversation.enabled():
                workflow = getToolByName(self.context, 'portal_workflow')
                cvalues = conversation.values()
                return len([c for c in  cvalues \
                    if workflow.getInfoFor(c, 'review_state') == 'published'])