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