xjc vor 5 Jahren
Ursprung
Commit
b4289699ce
2 geänderte Dateien mit 20 neuen und 0 gelöschten Zeilen
  1. 19 0
      src/manage/controls.py
  2. 1 0
      src/manage/views.py

+ 19 - 0
src/manage/controls.py

@@ -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 = []

+ 1 - 0
src/manage/views.py

@@ -585,6 +585,7 @@ class SignupDownloadZipView(cv.AdminView):
         """
         try:
             zipfile = ctl.download_zip(request)
+            print zipfile
             wrapper = FileWrapper(zipfile)
             response = HttpResponse(wrapper, content_type='application/zip')
             response['Content-Disposition'] = 'attachment;filename={}'\