add: 增加clone paper 代码
This commit is contained in:
parent
5274960945
commit
a661124534
|
@ -270,6 +270,35 @@ class PaperViewSet(ModelViewSet):
|
||||||
PaperQuestion.objects.filter(paper=paper).delete()
|
PaperQuestion.objects.filter(paper=paper).delete()
|
||||||
PaperQuestion.objects.bulk_create(q_list)
|
PaperQuestion.objects.bulk_create(q_list)
|
||||||
return Response()
|
return Response()
|
||||||
|
|
||||||
|
|
||||||
|
@action(methods=['put'], detail=True, url_path='clone', url_name='clone_paper',
|
||||||
|
perms_map=[{'put':'clone_paper'}])
|
||||||
|
def clone(self, request, pk=None):
|
||||||
|
'''
|
||||||
|
克隆试卷
|
||||||
|
'''
|
||||||
|
paper = self.get_object()
|
||||||
|
obj = Paper()
|
||||||
|
obj.name = '克隆卷-'+paper.name
|
||||||
|
obj.workscope = paper.workscope
|
||||||
|
obj.limit = paper.limit
|
||||||
|
obj.total_score = paper.total_score
|
||||||
|
obj.pass_score = paper.pass_score
|
||||||
|
obj.danxuan_count = paper.danxuan_count
|
||||||
|
obj.danxuan_score = paper.danxuan_score
|
||||||
|
obj.duoxuan_count = paper.duoxuan_count
|
||||||
|
obj.duoxuan_score = paper.duoxuan_score
|
||||||
|
obj.panduan_count = paper.panduan_count
|
||||||
|
obj.panduan_score = paper.panduan_score
|
||||||
|
obj.save()
|
||||||
|
for i in PaperQuestion.objects.filter(paper=paper):
|
||||||
|
o = PaperQuestion()
|
||||||
|
o.paper = obj
|
||||||
|
o.question = i.question
|
||||||
|
o.total_score = i.total_score
|
||||||
|
o.save()
|
||||||
|
return Response(status=200)
|
||||||
|
|
||||||
@action(methods=['post'], detail=False, perms_map={'post': 'question'}, serializer_class=Serializer)
|
@action(methods=['post'], detail=False, perms_map={'post': 'question'}, serializer_class=Serializer)
|
||||||
def upload_paper(self, request):
|
def upload_paper(self, request):
|
||||||
|
@ -277,7 +306,6 @@ class PaperViewSet(ModelViewSet):
|
||||||
question_type = request.data.get('question_type')
|
question_type = request.data.get('question_type')
|
||||||
excel_path = settings.BASE_DIR + "/media/default/question.xlsx"
|
excel_path = settings.BASE_DIR + "/media/default/question.xlsx"
|
||||||
doc_path = settings.BASE_DIR + doc_path
|
doc_path = settings.BASE_DIR + doc_path
|
||||||
# excel_path = "C:\code\data\question.xlsx"
|
|
||||||
timenow = timezone.now().strftime('%Y%m%d%H%M%S')
|
timenow = timezone.now().strftime('%Y%m%d%H%M%S')
|
||||||
question_excel_name = "question_excel_"+timenow
|
question_excel_name = "question_excel_"+timenow
|
||||||
question_excel = os.path.join(os.path.dirname(excel_path), question_excel_name)
|
question_excel = os.path.join(os.path.dirname(excel_path), question_excel_name)
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
from .settings import *
|
from .settings import *
|
||||||
DEBUG = True
|
DEBUG = True
|
||||||
DATABASES = {
|
DATABASES = {
|
||||||
# 'default': {
|
'default': {
|
||||||
# 'ENGINE': 'django.db.backends.postgresql',
|
'ENGINE': 'django.db.backends.postgresql',
|
||||||
# 'NAME': 'cma',
|
'NAME': 'cma',
|
||||||
# 'USER': 'postgres',
|
'USER': 'postgres',
|
||||||
# 'PASSWORD': 'zcDsj2021',
|
'PASSWORD': 'zcDsj2021',
|
||||||
# 'HOST': '49.232.14.174',
|
'HOST': '49.232.14.174',
|
||||||
# 'PORT': '5432',
|
'PORT': '5432',
|
||||||
# },
|
},
|
||||||
# 'default': {
|
# 'default': {
|
||||||
# 'ENGINE': 'django.db.backends.postgresql',
|
# 'ENGINE': 'django.db.backends.postgresql',
|
||||||
# 'NAME': 'cma',
|
# 'NAME': 'cma',
|
||||||
|
@ -18,16 +18,14 @@ DATABASES = {
|
||||||
# # 'HOST': '1.203.161.102',
|
# # 'HOST': '1.203.161.102',
|
||||||
# 'PORT': '5432',
|
# 'PORT': '5432',
|
||||||
# }
|
# }
|
||||||
'default': {
|
# 'default': {
|
||||||
'ENGINE': 'django.db.backends.postgresql',
|
# 'ENGINE': 'django.db.backends.postgresql',
|
||||||
'NAME': 'cma',
|
# 'NAME': 'cma',
|
||||||
'USER': 'cma',
|
# 'USER': 'cma',
|
||||||
'PASSWORD': 'cma123',
|
# 'PASSWORD': 'cma123',
|
||||||
'HOST': '172.16.80.102',
|
# 'HOST': '172.16.80.102',
|
||||||
# 'HOST': '127.0.0.1',
|
# # 'HOST': '127.0.0.1',
|
||||||
# 'HOST':'1.203.161.101',
|
# # 'HOST':'1.203.161.101',
|
||||||
'PORT': '5432',
|
# 'PORT': '5432',
|
||||||
}
|
# }
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue