fix : exam/view
This commit is contained in:
parent
24552d5b28
commit
a4b7c5f897
|
@ -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):
|
||||||
|
|
Loading…
Reference in New Issue