- Timestamp:
- 14 Nov 2011, 10:01:17 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/students/viewlets.py
r7107 r7108 8 8 from waeup.sirp.browser import DEFAULT_IMAGE_PATH 9 9 from waeup.sirp.students.browser import ( 10 StudentClearanceDisplayFormPage, StudentClearanceManageFormPage) 10 StudentClearanceDisplayFormPage, StudentClearanceManageFormPage, 11 write_log_message) 11 12 from waeup.sirp.students.interfaces import IStudentClearance 12 13 … … 205 206 store = getUtility(IExtFileStore) 206 207 store.deleteFileByContext(context, attr=download_name) 208 write_log_message(view, 'deleted: %s' % download_name) 207 209 view.flash('File %s deleted.' % download_name) 208 210 return … … 227 229 ext.lower() 228 230 if ext != expected_ext: 229 view.flash('%s extension expected.' % expected_ext)231 view.flash('%s file extension expected.' % expected_ext) 230 232 return False 231 233 size = file_size(upload) … … 237 239 file_id = IFileStoreNameChooser(context).chooseName(attr=download_name) 238 240 store.createFile(file_id, upload) 241 write_log_message(view, 'uploaded: %s (%s)' % (download_name,upload.filename)) 242 view.flash('File %s uploaded.' % download_name) 239 243 return True 240 244 … … 276 280 grok.require('waeup.manageStudents') 277 281 mus = 1024 * 150 278 input_name = u'f orm.filename'282 input_name = u'filename' 279 283 280 284 def update(self): 281 285 self.max_upload_size = string_from_bytes(self.mus) 282 delete = self.request.form.get('delete', None) 283 if delete: 284 self.view.files_deleted += self.download_name 286 delete_button = self.request.form.get('delete', None) 287 if delete_button: 285 288 handle_file_delete( 286 289 context=self.context, view=self.view, … … 289 292 self.view.url(self.context, self.view.__name__)) 290 293 return 291 upload = self.request.form.get(self.input_name, None)292 if upload :293 # We got a fresh upload294 file_changed = handle_file_upload(295 upload, self.context, self.view, self.mus, self.download_name)296 if file_changed is False: # False is not None!297 self.view.redirect(298 self.view.url(self.context, self.view.__name__))299 return # error during file upload. Ignore other values300 else:301 self.view.files_changed += self.download_name294 upload_button = self.request.form.get('upload', None) 295 if upload_button: 296 upload = self.request.form.get(self.input_name, None) 297 if upload: 298 # We got a fresh upload 299 file_changed = handle_file_upload( 300 upload, self.context, self.view, self.mus, self.download_name) 301 if file_changed is False: # False is not None! 302 self.view.redirect( 303 self.view.url(self.context, self.view.__name__)) 304 return # error during file upload. Ignore other values 302 305 return 303 306 … … 313 316 """ 314 317 grok.order(1) 315 label = u'Birth Certificate (jp eg image):'318 label = u'Birth Certificate (jpg only):' 316 319 mus = 1024 * 150 317 320 download_name = u'birth_certificate.jpg' 318 input_name = u' form.birth_certificate'321 input_name = u'birth_certificate' 319 322 320 323 class Image(grok.View):
Note: See TracChangeset for help on using the changeset viewer.