This commit is contained in:
Cja committed 2025-01-10 16:23:44 +03:00
1 parent 62b59444e5
commit 5b073c6642
4 files changed
+15 -4

No files matched your search

+9 -2
View File
@@ -32,7 +32,7 @@ class GetVotes(APIView):
return status_filters.get(status, Vote.objects.none()).order_by('dateend')
def has_participated(self, employee, vote):
return Result.objects.filter(user=employee, answer__vote=vote).exists()
return Result.objects.filter(user=employee, answer__question__vote=vote).exists()
def create_vote(self, request):
vote = Vote(
@@ -55,7 +55,14 @@ class GetVotes(APIView):
questions.delete()
results = Result.objects.filter(answer__vote=vote)
results = Result.objects.filter(answer__question__vote=vote)
results.delete()
vote.delete()
def get_vote_results(self, request):
vote_id = request.data.get('vote_id')
vote = Vote.objects.get(id=vote_id)
results = Result.objects.filter(answer__question__vote=vote).values('answer__answer').annotate(count=Count('id'))
serialized_results = VoteResultSerializer(results, many=True).data
return Response(serialized_results)