fix :exam/view.py del examrecord

This commit is contained in:
zty 2024-06-18 13:35:21 +08:00
parent 5b785dfd79
commit cc2525b266
2 changed files with 10 additions and 6 deletions

View File

@ -500,12 +500,16 @@ export default {
type: "error",
})
.then(async () => {
await deleteUserExam(scope.row.id);
this.userList.splice(scope.row.index, 1);
this.$message.success("成功");
deleteUserExam(scope.row.id).then((res) => {
console.log(res);
if (res.code >= 200) {
// this.userList.splice(scope.row.index, 1);
this.$message.success("成功");
this.getList();
};
});
})
.catch((err) => {
});
},
async confirm(form) {

View File

@ -490,7 +490,7 @@ class ExamViewSet(CreateUpdateCustomMixin, ModelViewSet):
instance = self.get_object()
if ExamRecord.objects.filter(exam=instance).exists():
raise ParseError('存在考试记录,禁止删除')
instance.delete(soft=False)
instance.delete()
return Response(status=204)
@action(methods=['post'], detail=True, perms_map={'post': '*'}, serializer_class=Serializer, permission_classes = [IsAuthenticated])
@ -580,7 +580,7 @@ class ExamRecordViewSet(ListModelMixin, DestroyModelMixin, RetrieveModelMixin, G
return super().get_serializer_class()
def perform_destroy(self, instance): # 考试记录物理删除
instance.delete(soft=False)
instance.delete()
@action(methods=['post'], detail=False, perms_map={'post': '*'}, serializer_class=Serializer, permission_classes = [IsAuthenticated])
def clear(self, request, pk=None):