fixname
This commit is contained in:
1 parent
80453d4895
commit
ea19aca7ad
2 files changed
+7
-6
No files matched your search
@@ -86,17 +86,18 @@ class VoteDetail(generics.RetrieveUpdateDestroyAPIView):
|
|||||||
|
|
||||||
class VoteCreate(APIView):
|
class VoteCreate(APIView):
|
||||||
def post(self, request):
|
def post(self, request):
|
||||||
try:
|
|
||||||
vote = self.create_vote(request)
|
vote = self.create_vote(request)
|
||||||
|
try:
|
||||||
self.create_news(request, vote)
|
self.create_news(request, vote)
|
||||||
return Response({'status': 'success', 'message': 'Vote and news created successfully.'}, status=200)
|
return Response({'status': 'success', 'message': 'Vote and news created successfully.'}, status=200)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
print(e)
|
||||||
return Response({'status': 'error', 'message': str(e)}, status=400)
|
return Response({'status': 'error', 'message': str(e)}, status=400)
|
||||||
|
|
||||||
def create_vote(self, request):
|
def create_vote(self, request):
|
||||||
|
|
||||||
user = request.user
|
user = request.user
|
||||||
|
print(request.data)
|
||||||
# for test
|
# for test
|
||||||
# # user = DictEmployee.objects.get(login='9966-00-125')
|
# # user = DictEmployee.objects.get(login='9966-00-125')
|
||||||
# # user = User.objects.get(user=user)
|
# # user = User.objects.get(user=user)
|
||||||
@@ -124,7 +125,7 @@ class VoteCreate(APIView):
|
|||||||
break
|
break
|
||||||
|
|
||||||
question = Question(
|
question = Question(
|
||||||
question=question_data['text'],
|
name=question_data['text'],
|
||||||
vote=vote,
|
vote=vote,
|
||||||
file=question_image,
|
file=question_image,
|
||||||
numb=count,
|
numb=count,
|
||||||
@@ -140,7 +141,7 @@ class VoteCreate(APIView):
|
|||||||
answer_image = file
|
answer_image = file
|
||||||
break
|
break
|
||||||
Answer(
|
Answer(
|
||||||
answer=answer['text'],
|
name=answer['text'],
|
||||||
file=answer_image,
|
file=answer_image,
|
||||||
question=question
|
question=question
|
||||||
).save()
|
).save()
|
||||||
|
|||||||
@@ -40,7 +40,7 @@
|
|||||||
|
|
||||||
<!-- <v-card class="d-flex flex-fill" > -->
|
<!-- <v-card class="d-flex flex-fill" > -->
|
||||||
<div class="">
|
<div class="">
|
||||||
<div class="" >{{ question.question }}</div>
|
<div class="" >{{ question.name }}</div>
|
||||||
|
|
||||||
<v-row>
|
<v-row>
|
||||||
<div class="v-col align-self-center ">
|
<div class="v-col align-self-center ">
|
||||||
@@ -55,7 +55,7 @@
|
|||||||
|
|
||||||
<v-list-item density="compact" v-for="answer in question.answers" :key="answer.id"
|
<v-list-item density="compact" v-for="answer in question.answers" :key="answer.id"
|
||||||
:value="answer.id">
|
:value="answer.id">
|
||||||
{{ answer.answer }}
|
{{ answer.name }}
|
||||||
<template v-slot:prepend="{ isSelected }">
|
<template v-slot:prepend="{ isSelected }">
|
||||||
<v-list-item-action start>
|
<v-list-item-action start>
|
||||||
<v-checkbox-btn :model-value="isSelected"></v-checkbox-btn>
|
<v-checkbox-btn :model-value="isSelected"></v-checkbox-btn>
|
||||||
|
|||||||
Reference in new issue
Block a user