fix : exam/view

This commit is contained in:
zty 2024-06-14 14:43:50 +08:00
parent 24552d5b28
commit a4b7c5f897
1 changed files with 4 additions and 4 deletions

View File

@ -72,14 +72,14 @@ class QuestionViewSet(CreateUpdateCustomMixin, ModelViewSet):
""" """
删除题目 删除题目
""" """
instance = self.get_object() id = kwargs.get('pk', None)
id = instance.id
# 删除前进行校验,如果存在考试中不允许删除。 # 删除前进行校验,如果存在考试中不允许删除。
paperquestion = PaperQuestion.objects.filter(question_id=id).exists() paperquestion = PaperQuestion.objects.filter(question_id=id).exists()
print(paperquestion)
if paperquestion: if paperquestion:
return Response(('此试题存在考试中不允许删除'),status=403) return Response(('此试题存在考试中不允许删除'),status=403)
instance.delete(soft=False) Question.objects.filter(id=id).delete()
return Response(status=204) return Response(("删除成功"),status=204)
@action(methods=['post'], detail=False, url_name='enable_question', perms_map={'post': 'question'}, serializer_class=Serializer) @action(methods=['post'], detail=False, url_name='enable_question', perms_map={'post': 'question'}, serializer_class=Serializer)
def enable(self, request): def enable(self, request):