|
@@ -1,12 +1,14 @@
|
|
|
# coding=utf-8
|
|
|
|
|
|
import json
|
|
|
+from django.utils import timezone
|
|
|
from django.db import transaction
|
|
|
from rest_framework.viewsets import ReadOnlyModelViewSet
|
|
|
from rest_framework.decorators import action
|
|
|
from utils.permission import IsAdministrator
|
|
|
from utils import response_error, response_ok
|
|
|
from utils.custom_modelviewset import CustomModelViewSet
|
|
|
+from utils.exceptions import CustomError
|
|
|
from apps.system.models import SysLog
|
|
|
|
|
|
from apps.examination.exampaper.models import ExamPaper
|
|
@@ -50,6 +52,8 @@ class ExamViewSet(CustomModelViewSet):
|
|
|
|
|
|
with transaction.atomic():
|
|
|
exam = Exam.getById(pk)
|
|
|
+ if timezone.now() > exam.exam_time:
|
|
|
+ raise CustomError(u'考试已经开始,禁止修改!')
|
|
|
exam.change_examinee(user_ids)
|
|
|
exam.save()
|
|
|
SysLog.objects.addnew(self.request.user, SysLog.UPDATE, u'添加考生,id=%d' % exam.id, request.POST.get('user_ids'))
|
|
@@ -61,6 +65,8 @@ class ExamViewSet(CustomModelViewSet):
|
|
|
|
|
|
with transaction.atomic():
|
|
|
exam = Exam.getById(pk)
|
|
|
+ if timezone.now() > exam.exam_time:
|
|
|
+ raise CustomError(u'考试已经开始,禁止修改!')
|
|
|
exampaper = ExamPaper.getById(exampaper_id)
|
|
|
exam.allocation_exampaper(Exam.FIXED, exampaper)
|
|
|
exam.save()
|
|
@@ -73,6 +79,8 @@ class ExamViewSet(CustomModelViewSet):
|
|
|
|
|
|
with transaction.atomic():
|
|
|
exam = Exam.getById(pk)
|
|
|
+ if timezone.now() > exam.exam_time:
|
|
|
+ raise CustomError(u'考试已经开始,禁止修改!')
|
|
|
|
|
|
data['name'] = exam.name
|
|
|
data['type'] = ExamPaper.RANDOM
|