コード例 #1
0
ファイル: conversation.py プロジェクト: Vinsurya/Plone
 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)
コード例 #2
0
 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)
コード例 #3
0
 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._comments[comment_key]
         if user_nobody.has_permission('View', comment):
             return comment.creation_date
     return None
コード例 #4
0
ファイル: conversation.py プロジェクト: Vinsurya/Plone
 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._comments[comment_key]
         if user_nobody.has_permission('View', comment):
             return comment.creation_date
     return None
コード例 #5
0
    def test_view_permission(self):
        """Test that if the View permission on Discussion Items is acquired,
        Anonymous can view comments on published items."""

        # Anonymous has View permission on commented objects.
        self.assertTrue(_anonymousCanView(self.archetypes_object))
        self.assertTrue(_anonymousCanView(self.dexterity_object))
        self.assertTrue(
            user_nobody.has_permission("View", self.archetypes_object))
        self.assertTrue(
            user_nobody.has_permission("View", self.dexterity_object))

        # Anonymous also passes the user_nobody.has_permission() test
        # on comments.
        self.assertTrue(
            user_nobody.has_permission("View", self.archetypes_comment))
        self.assertTrue(
            user_nobody.has_permission("View", self.dexterity_comment))

        # Fails: Anonymous should therefore have View permission on the
        # comments when we use rolesOfPermission.
        self.assertTrue(_anonymousCanView(self.archetypes_comment))
        self.assertTrue(_anonymousCanView(self.dexterity_comment))
コード例 #6
0
    def public_comments(self):
        """Count total comments.

        The @property decorator used on ``total_comments`` method doesn't work
        when combined with acquisition, that's a fact of life.

        Thus the total_comments indexer (on p.a.discussion.catalog.py) fails
        to index properly if acquisition is involved.

        To solve it, this method takes over the indexing and is being used by
        total_comments itself so that backwards compatibility is kept.
        """
        public_comments = [
            x for x in self.values() if user_nobody.has_permission('View', x)
        ]
        return len(public_comments)
コード例 #7
0
ファイル: conversation.py プロジェクト: CGTIC/Plone_SP
    def public_comments(self):
        """Count total comments.

        The @property decorator used on ``total_comments`` method doesn't work
        when combined with acquisition, that's a fact of life.

        Thus the total_comments indexer (on p.a.discussion.catalog.py) fails
        to index properly if acquisition is involved.

        To solve it, this method takes over the indexing and is being used by
        total_comments itself so that backwards compatibility is kept.
        """
        public_comments = [
            x for x in self.values()
            if user_nobody.has_permission('View', x)
        ]
        return len(public_comments)
コード例 #8
0
 def total_comments(self):
     public_comments = [
         x for x in self._comments.values()
         if user_nobody.has_permission('View', x)
     ]
     return len(public_comments)
コード例 #9
0
ファイル: conversation.py プロジェクト: Vinsurya/Plone
 def total_comments(self):
     public_comments = [
         x for x in self._comments.values()
         if user_nobody.has_permission('View', x)
     ]
     return len(public_comments)