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


Python services.add_vote函数代码示例

本文整理汇总了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;未经允许,请勿转载。