fix: exam/view 修改返回值

This commit is contained in:
zty 2024-06-14 15:30:33 +08:00
parent e289c3f453
commit 9c70761a51
1 changed files with 3 additions and 4 deletions

View File

@ -75,11 +75,10 @@ class QuestionViewSet(CreateUpdateCustomMixin, ModelViewSet):
id = kwargs.get('pk', None)
# 删除前进行校验,如果存在考试中不允许删除。
paperquestion = PaperQuestion.objects.filter(question_id=id).exists()
print(paperquestion)
if paperquestion:
return Response(('此试题存在考试中不允许删除'),status=403)
raise ParseError('此试题存在考试中不允许删除')
Question.objects.filter(id=id).delete()
return Response(("删除成功"),status=204)
return Response("删除成功")
@action(methods=['post'], detail=False, url_name='enable_question', perms_map={'post': 'question'}, serializer_class=Serializer)
def enable(self, request):
@ -103,7 +102,7 @@ class QuestionViewSet(CreateUpdateCustomMixin, ModelViewSet):
# 删除前进行校验,如果存在考试中不允许删除。
paperquestion = PaperQuestion.objects.filter(question__id__in=ids).exists()
if paperquestion:
return Response(('此试题存在考试中不允许删除'),status=403)
return Response('此试题存在考试中不允许删除')
Question.objects.filter(id__in=ids).update(is_deleted=True)
return Response()
return Response({'msg':'权限不足'},status=401)