Changeset 7081 for main/waeup.sirp/trunk/src/waeup
- Timestamp:
- 11 Nov 2011, 10:04:00 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/applicants/browser.py
r7068 r7081 58 58 from waeup.sirp.permissions import get_users_with_local_roles 59 59 from waeup.sirp.university.interfaces import ICertificate 60 from waeup.sirp.utils.helpers import string_from_bytes, file_size 60 61 from waeup.sirp.widgets.datewidget import ( 61 62 FriendlyDateWidget, FriendlyDateDisplayWidget) … … 67 68 IApplicant, IApplicantPrincipal,IApplicantEdit, IApplicantsRoot, 68 69 IApplicantsContainer, IApplicantsContainerAdd, application_types_vocab, 69 IMAGE_PATH, 70 IMAGE_PATH, MAX_UPLOAD_SIZE, 70 71 ) 71 72 from waeup.sirp.applicants.workflow import INITIALIZED, STARTED … … 695 696 target = 'edit_full' 696 697 697 def handle_img_upload(upload, context): 698 699 def handle_img_upload(upload, context, view): 698 700 """Handle upload of applicant image. 699 """ 701 702 Returns `True` in case of success or `False`. 703 704 Please note that file pointer passed in (`upload`) most probably 705 points to end of file when leaving this function. 706 """ 707 size = file_size(upload) 708 if size > MAX_UPLOAD_SIZE: 709 view.flash('Uploaded image is too big!') 710 return False 711 upload.seek(0) # file pointer moved when determining size 700 712 store = getUtility(IExtFileStore) 701 713 file_id = IFileStoreNameChooser(context).chooseName() 702 714 store.createFile(file_id, upload) 703 upload.seek(0) # XXX: really neccessary? 704 return 715 return True 705 716 706 717 class EditApplicantFull(WAeUPEditFormPage): … … 720 731 super(EditApplicantFull, self).update() 721 732 self.wf_info = IWorkflowInfo(self.context) 733 self.max_upload_size = string_from_bytes(MAX_UPLOAD_SIZE) 722 734 upload = self.request.form.get('form.passport', None) 723 735 if upload: 724 736 # We got a fresh upload 725 handle_img_upload(upload, self.context) 726 self.passport_changed = True 737 passport_changed = handle_img_upload(upload, self.context, self) 727 738 return 728 739 … … 789 800 return 790 801 datepicker.need() # Enable jQuery datepicker in date fields. 791 upload = self.request.form.get('form.passport', None)792 if upload:793 # We got a fresh upload794 handle_img_upload(upload, self.context)795 self.passport_changed = True796 802 super(EditApplicantStudent, self).update() 797 803 return
Note: See TracChangeset for help on using the changeset viewer.