P-106
This commit is contained in:
1 parent
cabdbf9ccf
commit
e26460f05b
1 file changed
+6
@@ -133,10 +133,15 @@ class GetResults(APIView):
|
|||||||
|
|
||||||
def get(self, request):
|
def get(self, request):
|
||||||
vote_id = request.data.get('id')
|
vote_id = request.data.get('id')
|
||||||
|
try:
|
||||||
vote = Vote.objects.get(id=vote_id)
|
vote = Vote.objects.get(id=vote_id)
|
||||||
|
except Exception as e:
|
||||||
|
return Response({'status': 'error', 'message': str(e)}, status=400)
|
||||||
|
|
||||||
answers_employee = Answer.objects.filter(question__vote=vote).filter(question__settings__choice="employee").values_list('answer', flat=True)
|
answers_employee = Answer.objects.filter(question__vote=vote).filter(question__settings__choice="employee").values_list('answer', flat=True)
|
||||||
results = Result.objects.filter(answer__question__vote=vote).annotate(count=Count('id')).values('answer__answer').annotate(count=Count('id'))
|
results = Result.objects.filter(answer__question__vote=vote).annotate(count=Count('id')).values('answer__answer').annotate(count=Count('id'))
|
||||||
|
|
||||||
|
if answers_employee:
|
||||||
employees = DictEmployee.objects.filter(id__in=answers_employee)
|
employees = DictEmployee.objects.filter(id__in=answers_employee)
|
||||||
employee_dict = {employee.id: employee for employee in employees}
|
employee_dict = {employee.id: employee for employee in employees}
|
||||||
|
|
||||||
@@ -151,6 +156,7 @@ class GetResults(APIView):
|
|||||||
|
|
||||||
from rest_framework.views import exception_handler
|
from rest_framework.views import exception_handler
|
||||||
class VoteResultCreate(APIView):
|
class VoteResultCreate(APIView):
|
||||||
|
|
||||||
def post(self, request):
|
def post(self, request):
|
||||||
|
|
||||||
# print(request.data)
|
# print(request.data)
|
||||||
|
|||||||
Reference in new issue
Block a user