- Timestamp:
- 18 Nov 2014, 11:37:28 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/files.py
r11972 r11985 36 36 CustomerFilesUploadPage) 37 37 38 grok.context(IIkobaObject) # Make IIkobaObject the default context38 grok.context(IIkobaObject) # Make IIkobaObject the default context 39 39 grok.templatedir('browser_templates') 40 40 41 41 42 def handle_file_delete(context, view, download_name): … … 46 47 store.deleteFileByContext(context, attr=download_name) 47 48 context.writeLogMessage(view, 'deleted: %s' % download_name) 48 view.flash(_('${a} deleted.', mapping = {'a':download_name}))49 view.flash(_('${a} deleted.', mapping={'a': download_name})) 49 50 return 51 50 52 51 53 def handle_file_upload(upload, context, view, max_size, download_name=None): … … 62 64 view.flash(_('Uploaded file is too big.'), type="danger") 63 65 return False 64 upload.seek(0) # file pointer moved when determining size66 upload.seek(0) # file pointer moved when determining size 65 67 dummy,ext = os.path.splitext(upload.filename) 66 68 # fpm files are expected to be fingerprint minutiae, file … … 70 72 else: 71 73 file_format = get_fileformat(None, upload.read(512)) 72 upload.seek(0) # same here74 upload.seek(0) # same here 73 75 if file_format is None: 74 76 view.flash(_('Could not determine file type.'), type="danger") … … 78 80 if '.' + file_format != expected_ext: 79 81 view.flash(_('${a} file extension expected.', 80 mapping = {'a':expected_ext[1:]}), type="danger")82 mapping={'a': expected_ext[1:]}), type="danger") 81 83 return False 82 84 else: … … 84 86 view.flash( 85 87 _('Only the following extensions are allowed: ${a}', 86 mapping = {'a':', '.join(ALLOWED_FILE_EXTENSIONS)}),88 mapping={'a': ', '.join(ALLOWED_FILE_EXTENSIONS)}), 87 89 type="danger") 88 90 return False … … 93 95 context.writeLogMessage(view, 'uploaded: %s (%s)' % ( 94 96 download_name,upload.filename)) 95 view.flash(_('File ${a} uploaded.', mapping = {'a':download_name}))97 view.flash(_('File ${a} uploaded.', mapping={'a': download_name})) 96 98 return True 99 97 100 98 101 class FileManager(grok.ViewletManager): … … 100 103 """ 101 104 grok.name('files') 105 102 106 103 107 class FileDisplay(grok.Viewlet): … … 123 127 else: 124 128 return False 129 125 130 126 131 class FileUpload(FileDisplay): … … 179 184 return 180 185 186 181 187 class PassportDisplay(FileDisplay): 182 188 """Passport display viewlet. … … 188 194 label = _(u'Passport Picture') 189 195 download_name = u'passport.jpg' 196 190 197 191 198 class PassportUploadManage(FileUpload): … … 201 208 tab_redirect = '#tab2' 202 209 210 203 211 class PassportUploadEdit(PassportUploadManage): 204 212 """Passport upload viewlet for customers. … … 206 214 grok.view(CustomerFilesUploadPage) 207 215 grok.require('waeup.uploadCustomerFile') 216 208 217 209 218 class Image(grok.View): … … 238 247 return image 239 248 249 240 250 class Passport(Image): 241 251 """Renders jpeg passport picture. … … 244 254 download_name = u'passport.jpg' 245 255 grok.context(ICustomer) 246
Note: See TracChangeset for help on using the changeset viewer.