导出考试信息带图片
This commit is contained in:
parent
0a61fffe7a
commit
886f2eca76
|
@ -71,9 +71,9 @@ App({
|
||||||
userInfo: {},
|
userInfo: {},
|
||||||
userinfo: {}, // 服务器传回的消费者信息
|
userinfo: {}, // 服务器传回的消费者信息
|
||||||
//host: 'https://apitest.ahctc.cn',
|
//host: 'https://apitest.ahctc.cn',
|
||||||
mediahost: 'https://apitest.ahctc.cn',
|
//mediahost: 'https://apitest.ahctc.cn',
|
||||||
host: 'http://127.0.0.1:8000',
|
host: 'http://127.0.0.1:8000',
|
||||||
//mediahost: 'http://127.0.0.1:8000',
|
mediahost: 'http://127.0.0.1:8000',
|
||||||
token : '',
|
token : '',
|
||||||
rlogin:true
|
rlogin:true
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,17 +34,19 @@ def exportw_test(obj, bool):
|
||||||
"""
|
"""
|
||||||
导出个人考试记录word版本
|
导出个人考试记录word版本
|
||||||
"""
|
"""
|
||||||
filename = obj.exam.name + '-' + obj.consumer.name + '-' + obj.consumer.username + '.docx'
|
filename = obj.exam.name + '-' + str(obj.exam.id) + '-' + obj.consumer.name + '-' + obj.consumer.username + '.docx'
|
||||||
path = '/media/export/' + filename
|
path = '/media/export/' + filename
|
||||||
fullpath = BASE_DIR + path
|
fullpath = BASE_DIR + path
|
||||||
if bool or (not os.path.exists(fullpath)):
|
if bool or (not os.path.exists(fullpath)):
|
||||||
data = ExamTestDetailSerializer(instance=obj).data
|
data = ExamTestDetailSerializer(instance=obj).data
|
||||||
#开始生成word
|
#开始生成word
|
||||||
doc = DocxTemplate(BASE_DIR + "/tmp/examtest.docx")
|
doc = DocxTemplate(BASE_DIR + "/tmp/examtest.docx")
|
||||||
for i in data['qdimgs']:
|
data['qdimgs'] = []
|
||||||
i = InlineImage(doc, BASE_DIR + i,width=Mm(40))
|
data['xcimgs'] = []
|
||||||
for i in data['xcimgs']:
|
for i in data['exam_']['qdimgs']:
|
||||||
i = InlineImage(doc, BASE_DIR + i,width=Mm(40))
|
data['qdimgs'].append(InlineImage(doc, BASE_DIR + i,width=Mm(40)))
|
||||||
|
for i in data['exam_']['xcimgs']:
|
||||||
|
data['xcimgs'].append(InlineImage(doc, BASE_DIR + i,width=Mm(40)))
|
||||||
doc.render(data)
|
doc.render(data)
|
||||||
doc.save(fullpath)
|
doc.save(fullpath)
|
||||||
# output = BytesIO()
|
# output = BytesIO()
|
||||||
|
|
Binary file not shown.
Loading…
Reference in New Issue