Example #1
0
    def downvote(self, request, pk=None):
        issue = get_object_or_404(models.Issue, pk=pk)

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

        votes_service.remove_vote(issue, user=request.user)
        return response.Ok()
Example #2
0
    def downvote(self, request, pk=None):
        issue = get_object_or_404(models.Issue, pk=pk)

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

        votes_service.remove_vote(issue, user=request.user)
        return Response(status=status.HTTP_200_OK)
Example #3
0
    def downvote(self, request, pk=None):
        obj = self.get_object()
        self.check_permissions(request, "downvote", obj)
        self.pre_conditions_on_save(obj)

        services.remove_vote(obj, user=request.user)
        return response.Ok()
Example #4
0
    def downvote(self, request, pk=None):
        obj = self.get_object()
        self.check_permissions(request, "downvote", obj)
        self.pre_conditions_on_save(obj)

        services.remove_vote(obj, user=request.user)
        return response.Ok()
Example #5
0
def test_remove_vote():
    user = f.UserFactory()
    project = f.ProjectFactory()
    project_type = ContentType.objects.get_for_model(project)
    votes_qs = models.Votes.objects.filter(content_type=project_type, object_id=project.id)
    f.VotesFactory(content_type=project_type, object_id=project.id, count=1)
    f.VoteFactory(content_type=project_type, object_id=project.id, user=user)

    assert votes_qs.get().count == 1

    votes.remove_vote(project, user)

    assert votes_qs.get().count == 0

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

    assert votes_qs.get().count == 0
def test_remove_vote():
    user = f.UserFactory()
    project = f.ProjectFactory()
    project_type = ContentType.objects.get_for_model(project)
    votes_qs = models.Votes.objects.filter(content_type=project_type, object_id=project.id)
    f.VotesFactory(content_type=project_type, object_id=project.id, count=1)
    f.VoteFactory(content_type=project_type, object_id=project.id, user=user)

    assert votes_qs.get().count == 1

    votes.remove_vote(project, user)

    assert votes_qs.get().count == 0

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

    assert votes_qs.get().count == 0
Example #7
0
    def _remove_vote(self, permission, request, pk=None):
        obj = self.get_object()
        self.check_permissions(request, permission, obj)

        services.remove_vote(obj, user=request.user)
        return response.Ok()
Example #8
0
 def downvote(self, request, pk=None):
     issue = self.get_object()
     votes_service.remove_vote(issue, user=request.user)
     return Response(status=status.HTTP_200_OK)
Example #9
0
    def _remove_vote(self, permission, request, pk=None):
        obj = self.get_object()
        self.check_permissions(request, permission, obj)

        services.remove_vote(obj, user=request.user)
        return response.Ok()