Merge branch 'сja' into dev-denzel
This commit is contained in:
commit
f34ca3c569
6 files changed
+33
-14
No files matched your search
+12
-5
@@ -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(
|
||||
@@ -45,9 +45,9 @@ class GetVotes(APIView):
|
||||
)
|
||||
vote.save()
|
||||
|
||||
def delete_vote_by_name(self,request):
|
||||
vote_name = request.data.get('vote_name')
|
||||
vote = Vote.objects.get(name=vote_name)
|
||||
def delete_vote(self,request):
|
||||
vote_id = request.data.get('vote_id')
|
||||
vote = Vote.objects.get(id=vote_id)
|
||||
questions = vote.questions.all()
|
||||
for question in questions:
|
||||
answers = question.answers.all()
|
||||
@@ -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)
|
||||
Reference in new issue
Block a user