- Timestamp:
- 4 Nov 2011, 18:36:27 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/branches/ulif-extimgstore/src/waeup/sirp/applicants/browser.py
r6816 r7002 22 22 """UI components for basic applicants and related components. 23 23 """ 24 import os 24 25 import sys 25 26 import grok … … 57 58 ) 58 59 from waeup.sirp.image.image import createWAeUPImageFile 59 from waeup.sirp.interfaces import IWAeUPObject, ILocalRolesAssignable 60 from waeup.sirp.interfaces import ( 61 IWAeUPObject, ILocalRolesAssignable, IExtFileStore, IFileStoreNameChooser) 60 62 from waeup.sirp.permissions import get_users_with_local_roles 61 63 from waeup.sirp.university.interfaces import ICertificate … … 65 67 from waeup.sirp.widgets.objectwidget import ( 66 68 WAeUPObjectWidget, WAeUPObjectDisplayWidget) 67 from waeup.sirp.applicants import ResultEntry, Applicant, get_applicant_data 69 from waeup.sirp.applicants import ( 70 ResultEntry, Applicant, get_applicant_data, get_regno_or_ac) 68 71 from waeup.sirp.applicants.interfaces import ( 69 72 IApplicant, IApplicantPrincipal,IApplicantEdit, IApplicantsRoot, 70 IApplicantsContainer, IApplicantsContainerAdd, application_types_vocab 73 IApplicantsContainer, IApplicantsContainerAdd, application_types_vocab, 74 IMAGE_PATH, 71 75 ) 72 76 from waeup.sirp.applicants.workflow import INITIALIZED, STARTED … … 551 555 'locked').omit('course_admitted') 552 556 #form_fields['fst_sit_results'].custom_widget = list_results_display_widget 553 form_fields['passport'].custom_widget = ThumbnailWidget557 #form_fields['passport'].custom_widget = ThumbnailWidget 554 558 form_fields['date_of_birth'].custom_widget = FriendlyDateDisplayWidget('le') 555 559 label = 'Applicant' 556 560 grok.template('form_display') 557 561 pnav = 3 562 563 def update(self): 564 self.passport_url = self.url(self.context, 'passport.jpg') 565 return 558 566 559 567 @property … … 705 713 grok.require('waeup.manageApplications') 706 714 form_fields = grok.AutoFields(IApplicant) 707 form_fields['passport'].custom_widget = EncodingImageFileWidget715 #form_fields['passport'].custom_widget = EncodingImageFileWidget 708 716 form_fields['date_of_birth'].custom_widget = FriendlyDateWidget('le-year') 709 717 grok.template('form_edit') … … 718 726 if upload: 719 727 # We got a fresh upload 720 image = createWAeUPImageFile(upload.filename, upload) 728 #from waeup.sirp.interfaces import IExtFileStorage 729 #from zope.component import queryUtility 730 #storage = queryUtility(IExtFileStorage) 731 # filename = '__img_appl__' + str(self.context.reg_no) #upload.filename 732 from waeup.sirp.interfaces import ( 733 IExtFileStore, IFileStoreNameChooser) 734 store = getUtility(IExtFileStore) 735 file_id = IFileStoreNameChooser(self.context).chooseName() 736 store.createFile(file_id, upload) 737 #filename = '__img_appl__' + str( 738 # self.context.access_code) + '.jpg' #upload.filename 739 print "FILENAME: ", file_id 740 # image = createWAeUPImageFile(upload.filename, upload) 741 #image = createWAeUPImageFile(filename, upload) 721 742 # This would normally be totally illegal. We set context 722 743 # data without the complete form data being … … 731 752 # we set the image here and not in 'save()' or other 732 753 # methods. 733 self.context.passport = image754 #self.context.passport = image 734 755 upload.seek(0) 735 756 self.passport_changed = True … … 782 803 'screening_score', 783 804 ) 784 form_fields['passport'].custom_widget = EncodingImageFileWidget805 #form_fields['passport'].custom_widget = EncodingImageFileWidget 785 806 form_fields['date_of_birth'].custom_widget = FriendlyDateWidget('le-year') 786 807 grok.template('form_edit') … … 868 889 text = 'View application record' 869 890 target = 'index' 891 892 class PassportImage(grok.View): 893 """Renders the passport image for applicants. 894 """ 895 grok.name('passport.jpg') 896 grok.context(IApplicant) 897 grok.require('waeup.handleApplication') 898 899 def render(self): 900 # A filename chooser turns a context into a filename suitable 901 # for file storage. 902 chooser = IFileStoreNameChooser(self.context) 903 file_id = chooser.chooseName() 904 image = getUtility(IExtFileStore).getFile(file_id) 905 self.response.setHeader( 906 'Content-Type', 'image/jpeg') 907 if image is None: 908 # show placeholder image 909 return open(os.path.join(IMAGE_PATH, 'placeholder_m.jpg'), 'rb') 910 return image
Note: See TracChangeset for help on using the changeset viewer.