当前位置: 首页>>代码示例>>Python>>正文


Python Comment.find_n_unread方法代码示例

本文整理汇总了Python中osf.models.Comment.find_n_unread方法的典型用法代码示例。如果您正苦于以下问题:Python Comment.find_n_unread方法的具体用法?Python Comment.find_n_unread怎么用?Python Comment.find_n_unread使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在osf.models.Comment的用法示例。


在下文中一共展示了Comment.find_n_unread方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_find_unread_new_comments

# 需要导入模块: from osf.models import Comment [as 别名]
# 或者: from osf.models.Comment import find_n_unread [as 别名]
 def test_find_unread_new_comments(self):
     project = ProjectFactory()
     user = UserFactory()
     project.add_contributor(user, save=True)
     CommentFactory(node=project, user=project.creator)
     n_unread = Comment.find_n_unread(user=user, node=project, page='node')
     assert n_unread == 1
开发者ID:erinspace,项目名称:osf.io,代码行数:9,代码来源:test_comment.py

示例2: get_paginated_response

# 需要导入模块: from osf.models import Comment [as 别名]
# 或者: from osf.models.Comment import find_n_unread [as 别名]
    def get_paginated_response(self, data):
        """Add number of unread comments to links.meta when viewing list of comments filtered by
        a target node, file or wiki page."""
        response = super(CommentPagination, self).get_paginated_response(data)
        response_dict = response.data
        kwargs = self.request.parser_context['kwargs'].copy()

        if self.request.query_params.get('related_counts', False):
            target_id = self.request.query_params.get('filter[target]', None)
            node_id = kwargs.get('node_id', None)
            node = Node.load(node_id)
            user = self.request.user
            if target_id and not user.is_anonymous and node.is_contributor(user):
                root_target = Guid.load(target_id)
                if root_target:
                    page = getattr(root_target.referent, 'root_target_page', None)
                    if page:
                        if not len(data):
                            unread = 0
                        else:
                            unread = Comment.find_n_unread(user=user, node=node, page=page, root_id=target_id)
                        if self.request.version < '2.1':
                            response_dict['links']['meta']['unread'] = unread
                        else:
                            response_dict['meta']['unread'] = unread
        return Response(response_dict)
开发者ID:adlius,项目名称:osf.io,代码行数:28,代码来源:pagination.py

示例3: get_unread_comments_count

# 需要导入模块: from osf.models import Comment [as 别名]
# 或者: from osf.models.Comment import find_n_unread [as 别名]
    def get_unread_comments_count(self, obj):
        user = get_user_auth(self.context['request']).user
        node_comments = Comment.find_n_unread(user=user, node=obj, page='node')

        return {
            'node': node_comments
        }
开发者ID:adlius,项目名称:osf.io,代码行数:9,代码来源:serializers.py

示例4: test_find_unread_does_not_include_deleted_comments

# 需要导入模块: from osf.models import Comment [as 别名]
# 或者: from osf.models.Comment import find_n_unread [as 别名]
 def test_find_unread_does_not_include_deleted_comments(self):
     project = ProjectFactory()
     user = AuthUserFactory()
     project.add_contributor(user)
     project.save()
     CommentFactory(node=project, user=project.creator, is_deleted=True)
     n_unread = Comment.find_n_unread(user=user, node=project, page='node')
     assert n_unread == 0
开发者ID:erinspace,项目名称:osf.io,代码行数:10,代码来源:test_comment.py

示例5: test_find_unread_includes_comment_replies

# 需要导入模块: from osf.models import Comment [as 别名]
# 或者: from osf.models.Comment import find_n_unread [as 别名]
 def test_find_unread_includes_comment_replies(self):
     project = ProjectFactory()
     user = UserFactory()
     project.add_contributor(user, save=True)
     comment = CommentFactory(node=project, user=user)
     CommentFactory(node=project, target=Guid.load(comment._id), user=project.creator)
     n_unread = Comment.find_n_unread(user=user, node=project, page='node')
     assert n_unread == 1
开发者ID:erinspace,项目名称:osf.io,代码行数:10,代码来源:test_comment.py

示例6: test_find_unread_is_zero_when_no_comments

# 需要导入模块: from osf.models import Comment [as 别名]
# 或者: from osf.models.Comment import find_n_unread [as 别名]
 def test_find_unread_is_zero_when_no_comments(self):
     n_unread = Comment.find_n_unread(user=UserFactory(), node=ProjectFactory(), page='node')
     assert n_unread == 0
开发者ID:erinspace,项目名称:osf.io,代码行数:5,代码来源:test_comment.py

示例7: get_unread_comments_count

# 需要导入模块: from osf.models import Comment [as 别名]
# 或者: from osf.models.Comment import find_n_unread [as 别名]
 def get_unread_comments_count(self, obj):
     user = self.context['request'].user
     if user.is_anonymous:
         return 0
     return Comment.find_n_unread(user=user, node=obj.node, page='files', root_id=obj.get_guid()._id)
开发者ID:leb2dg,项目名称:osf.io,代码行数:7,代码来源:serializers.py


注:本文中的osf.models.Comment.find_n_unread方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。