|
|
@@ -26,6 +26,15 @@ import xlwt
|
|
|
from xlutils.copy import copy
|
|
|
from xltpl.writer import BookWriter
|
|
|
|
|
|
+def thumbnail_pic(fpath):
|
|
|
+ """
|
|
|
+ """
|
|
|
+ im=Image.open(fpath)
|
|
|
+ im.thumbnail((300,400))
|
|
|
+ thumb_name = os.path.splitext(fpath)[0]+"_thumb"+os.path.splitext(fpath)[-1]
|
|
|
+ im.save(thumb_name,'JPEG')
|
|
|
+ return thumb_name
|
|
|
+
|
|
|
def render_xls_tpl(tpl,data,out):
|
|
|
"""
|
|
|
"""
|
|
|
@@ -1504,6 +1513,13 @@ def download_zip(request):
|
|
|
oldcard_img = o.oldcard_img.replace(settings.HOST,settings.STATIC_ROOT) if o.oldcard_img else None
|
|
|
classhour_cert_url = o.classhour_cert_url.replace(settings.HOST,settings.STATIC_ROOT) if o.classhour_cert_url else None
|
|
|
halfbody_img = o.halfbody_img.replace(settings.HOST,settings.STATIC_ROOT) if o.halfbody_img else None
|
|
|
+
|
|
|
+ idnoimg_face = thumbnail_pic(idnoimg_face) if idnoimg_face else None
|
|
|
+ idnoimg_back = thumbnail_pic(idnoimg_back) if idnoimg_back else None
|
|
|
+ education_img = thumbnail_pic(education_img) if education_img else None
|
|
|
+ oldcard_img = thumbnail_pic(oldcard_img) if oldcard_img else None
|
|
|
+ classhour_cert_url = thumbnail_pic(classhour_cert_url) if classhour_cert_url else None
|
|
|
+ halfbody_img = thumbnail_pic(halfbody_img) if halfbody_img else None
|
|
|
context = {"name":o.name,"sex":o.sex,"education":o.education,"idno":o.idno,"class_id":o.class_id,
|
|
|
"company":o.company,"phone":o.phone,"train_type":o.train_type,"subject_item1":subject_item1,
|
|
|
"subject_item2":subject_item2,"train_time_start":o.train_time_start,"subject_item_code":subject_item_code,
|
|
|
@@ -1525,6 +1541,9 @@ def download_zip(request):
|
|
|
doc.save(fname)
|
|
|
files.append(fname)
|
|
|
except Exception as e:
|
|
|
+ import traceback
|
|
|
+ traceback.print_exc()
|
|
|
+ print e,8888888888888
|
|
|
continue
|
|
|
else:
|
|
|
files = []
|