• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python services.add_vote函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中taiga.projects.votes.services.add_vote函数的典型用法代码示例。如果您正苦于以下问题:Python add_vote函数的具体用法?Python add_vote怎么用?Python add_vote使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: upvote

    def upvote(self, request, pk=None):
        obj = self.get_object()
        self.check_permissions(request, "upvote", obj)
        self.pre_conditions_on_save(obj)

        services.add_vote(obj, user=request.user)
        return response.Ok()
开发者ID:rubixware,项目名称:taiga-back,代码行数:7,代码来源:viewsets.py


示例2: upvote

    def upvote(self, request, pk=None):
        issue = get_object_or_404(models.Issue, pk=pk)

        self.check_permissions(request, 'upvote', issue)

        votes_service.add_vote(issue, user=request.user)
        return response.Ok()
开发者ID:lcyhff,项目名称:taiga-back,代码行数:7,代码来源:api.py


示例3: test_add_vote

def test_add_vote():
    project = f.ProjectFactory()
    project_type = ContentType.objects.get_for_model(project)
    user = f.UserFactory()
    votes_qs = models.Votes.objects.filter(content_type=project_type, object_id=project.id)

    votes.add_vote(project, user)

    assert votes_qs.get().count == 1

    votes.add_vote(project, user)  # add_vote must be idempotent

    assert votes_qs.get().count == 1
开发者ID:0-T-0,项目名称:taiga-back,代码行数:13,代码来源:test_votes.py


示例4: test_user_story_voters_retrieve

def test_user_story_voters_retrieve(client, data):
    add_vote(data.public_user_story, data.project_owner)
    public_url = reverse('userstory-voters-detail', kwargs={"resource_id": data.public_user_story.pk,
                                                            "pk": data.project_owner.pk})
    add_vote(data.private_user_story1, data.project_owner)
    private_url1 = reverse('userstory-voters-detail', kwargs={"resource_id": data.private_user_story1.pk,
                                                              "pk": data.project_owner.pk})
    add_vote(data.private_user_story2, data.project_owner)
    private_url2 = reverse('userstory-voters-detail', kwargs={"resource_id": data.private_user_story2.pk,
                                                              "pk": data.project_owner.pk})

    add_vote(data.blocked_user_story, data.project_owner)
    blocked_url = reverse('userstory-voters-detail', kwargs={"resource_id": data.blocked_user_story.pk,
                                                              "pk": data.project_owner.pk})
    users = [
        None,
        data.registered_user,
        data.project_member_without_perms,
        data.project_member_with_perms,
        data.project_owner
    ]

    results = helper_test_http_method(client, 'get', public_url, None, users)
    assert results == [200, 200, 200, 200, 200]
    results = helper_test_http_method(client, 'get', private_url1, None, users)
    assert results == [200, 200, 200, 200, 200]
    results = helper_test_http_method(client, 'get', private_url2, None, users)
    assert results == [401, 403, 403, 200, 200]
    results = helper_test_http_method(client, 'get', blocked_url, None, users)
    assert results == [401, 403, 403, 200, 200]
开发者ID:CrypticGator,项目名称:taiga-back,代码行数:30,代码来源:test_userstories_resources.py


示例5: test_issue_voters_retrieve

def test_issue_voters_retrieve(client, data):
    add_vote(data.public_issue, data.project_owner)
    public_url = reverse('issue-voters-detail', kwargs={"issue_id": data.public_issue.pk, "pk": data.project_owner.pk})
    add_vote(data.private_issue1, data.project_owner)
    private_url1 = reverse('issue-voters-detail', kwargs={"issue_id": data.private_issue1.pk, "pk": data.project_owner.pk})
    add_vote(data.private_issue2, data.project_owner)
    private_url2 = reverse('issue-voters-detail', kwargs={"issue_id": data.private_issue2.pk, "pk": data.project_owner.pk})

    users = [
        None,
        data.registered_user,
        data.project_member_without_perms,
        data.project_member_with_perms,
        data.project_owner
    ]

    results = helper_test_http_method(client, 'get', public_url, None, users)
    assert results == [200, 200, 200, 200, 200]

    results = helper_test_http_method(client, 'get', private_url1, None, users)
    assert results == [200, 200, 200, 200, 200]

    results = helper_test_http_method(client, 'get', private_url2, None, users)
    assert results == [401, 403, 403, 200, 200]
开发者ID:lcyhff,项目名称:taiga-back,代码行数:24,代码来源:test_issues_resources.py


示例6: create_votes

 def create_votes(self, obj):
     for i in range(self.sd.int(*NUM_VOTES)):
         user=self.sd.db_object_from_queryset(User.objects.all())
         add_vote(obj, user)
开发者ID:cubettech,项目名称:taiga-back,代码行数:4,代码来源:sample_data.py


示例7: create_votes

 def create_votes(self, obj, project):
     for i in range(self.sd.int(*NUM_VOTES)):
         voting_user=self.sd.db_object_from_queryset(project.members.all())
         add_vote(obj, voting_user)
开发者ID:niibruce,项目名称:taiga-back,代码行数:4,代码来源:sample_data.py


示例8: _add_voter

    def _add_voter(self, permission, request, pk=None):
        obj = self.get_object()
        self.check_permissions(request, permission, obj)

        services.add_vote(obj, user=request.user)
        return response.Ok()
开发者ID:jinanwang,项目名称:taiga-back,代码行数:6,代码来源:viewsets.py


示例9: upvote

 def upvote(self, request, pk=None):
     issue = self.get_object()
     votes_service.add_vote(issue, user=request.user)
     return Response(status=status.HTTP_200_OK)
开发者ID:yamila-moreno,项目名称:taiga-back,代码行数:4,代码来源:api.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python services.get_voters函数代码示例发布时间:2022-05-27
下一篇:
Python services.apply_order_updates函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap