Changeset 7055 for main/waeup.sirp/branches
- Timestamp:
- 9 Nov 2011, 07:02:02 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/branches/ulif-extimgstore/src/waeup/sirp/applicants/browser.py
r7054 r7055 54 54 ManageActionButton, PrimaryNavTab, LeftSidebarLink 55 55 ) 56 from waeup.sirp.image.image import createWAeUPImageFile57 56 from waeup.sirp.interfaces import ( 58 57 IWAeUPObject, ILocalRolesAssignable, IExtFileStore, IFileStoreNameChooser) … … 425 424 # If application has ended and applicant record doesn't exist, 426 425 # logout without marking AC as used 427 if not pin in self.context.keys() and self.context.enddate < date.today(): 426 if not pin in self.context.keys() and ( 427 self.context.enddate < date.today()): 428 428 self.flash('Application has ended.') 429 429 auth = getUtility(IAuthentication) … … 433 433 434 434 # Mark AC as used (this also fires a pin related transition) 435 if get_access_code(pin).state == USED: 436 pass 437 else: 435 if get_access_code(pin).state != USED: 438 436 comment = u"AC invalidated" 439 437 # Here we know that the ac is in state initialized so we do not … … 514 512 applicant_object = get_applicant_data(access_code) 515 513 return absoluteURL(applicant_object, self.request) + self.target 516 #else: 517 # return '' 514 return '' 518 515 519 516 class AccessCodeEditLink(AccessCodeViewLink): … … 534 531 return '' 535 532 return absoluteURL(applicant_object, self.request) + self.target 536 #else: 537 # return '' 533 return '' 538 534 539 535 class AccessCodeSlipLink(AccessCodeViewLink): … … 550 546 form_fields = grok.AutoFields(IApplicant).omit( 551 547 'locked').omit('course_admitted') 552 #form_fields['fst_sit_results'].custom_widget = list_results_display_widget553 #form_fields['passport'].custom_widget = ThumbnailWidget554 548 form_fields['date_of_birth'].custom_widget = FriendlyDateDisplayWidget('le') 555 549 label = 'Applicant' … … 586 580 class PDFActionButton(ManageActionButton): 587 581 grok.context(IApplicant) 588 #grok.view(DisplayApplicant)589 582 grok.require('waeup.manageApplications') 590 583 icon = 'actionicon_pdf.png' … … 628 621 629 622 def render(self): 630 # (0,0),(-1,-1) = whole table631 # (0,0),(0,-1) = first column632 # (-1,0),(-1,-1) = last column633 # (0,0),(-1,0) = first row634 # (0,-1),(-1,-1) = last row635 623 SLIP_STYLE = TableStyle( 636 624 [('VALIGN',(0,0),(-1,-1),'TOP')] … … 705 693 target = 'edit_full' 706 694 695 def handle_img_upload(upload, context): 696 """Handle upload of applicant image. 697 """ 698 store = getUtility(IExtFileStore) 699 file_id = IFileStoreNameChooser(context).chooseName() 700 store.createFile(file_id, upload) 701 upload.seek(0) # XXX: really neccessary? 702 return 703 707 704 class EditApplicantFull(WAeUPEditFormPage): 708 705 """A full edit view for applicant data. … … 712 709 grok.require('waeup.manageApplications') 713 710 form_fields = grok.AutoFields(IApplicant) 714 #form_fields['passport'].custom_widget = EncodingImageFileWidget715 711 form_fields['date_of_birth'].custom_widget = FriendlyDateWidget('le-year') 716 712 grok.template('form_edit') … … 725 721 if upload: 726 722 # We got a fresh upload 727 #from waeup.sirp.interfaces import IExtFileStorage 728 #from zope.component import queryUtility 729 #storage = queryUtility(IExtFileStorage) 730 # filename = '__img_appl__' + str(self.context.reg_no) #upload.filename 731 store = getUtility(IExtFileStore) 732 file_id = IFileStoreNameChooser(self.context).chooseName() 733 store.createFile(file_id, upload) 734 #filename = '__img_appl__' + str( 735 # self.context.access_code) + '.jpg' #upload.filename 736 print "FILENAME: ", file_id 737 # image = createWAeUPImageFile(upload.filename, upload) 738 #image = createWAeUPImageFile(filename, upload) 739 # This would normally be totally illegal. We set context 740 # data without the complete form data being 741 # verified. Normally data is set in methods like `save` 742 # only, which is only called when all form data is correct 743 # (and if not, the context is not touched). With images 744 # and their uploads the problem then is, that the uploaded 745 # image won't be shown in a partially erranous form 746 # because the new uploaded image is still not part of the 747 # context obeject and the image widget cannot work around 748 # that (it has no access to the new data). For this reason 749 # we set the image here and not in 'save()' or other 750 # methods. 751 #self.context.passport = image 752 upload.seek(0) 723 handle_img_upload(upload, self.context) 753 724 self.passport_changed = True 754 725 return … … 778 749 changed_fields = self.applyData(self.context, **data) 779 750 changed_fields = changed_fields.values() 780 fields_string = '+'.join(' + '.join(str(i) for i in b) for b in changed_fields) 751 fields_string = '+'.join( 752 ' + '.join(str(i) for i in b) for b in changed_fields) 781 753 self.context._p_changed = True 782 754 form = self.request.form … … 800 772 'screening_score', 801 773 ) 802 #form_fields['passport'].custom_widget = EncodingImageFileWidget803 774 form_fields['date_of_birth'].custom_widget = FriendlyDateWidget('le-year') 804 775 grok.template('form_edit') … … 806 777 title = u'Your Application Form' 807 778 808 809 779 def emitLockMessage(self): 810 780 self.flash('The requested form is locked (read-only).') … … 820 790 if upload: 821 791 # We got a fresh upload 822 image = createWAeUPImageFile(upload.filename, upload) 823 # This would normally be totally illegal. We set context 824 # data without the complete form data being 825 # verified. Normally data is set in methods like `save` 826 # only, which is only called when all form data is correct 827 # (and if not, the context is not touched). With images 828 # and their uploads the problem then is, that the uploaded 829 # image won't be shown in a partially erranous form 830 # because the new uploaded image is still not part of the 831 # context obeject and the image widget cannot work around 832 # that (it has no access to the new data). For this reason 833 # we set the image here and not in 'save()' or other 834 # methods. 835 self.context.passport = image 836 upload.seek(0) 792 handle_img_upload(upload, self.context) 837 793 self.passport_changed = True 838 794 super(EditApplicantStudent, self).update() … … 842 798 if not self.request.form.get('confirm_passport', False): 843 799 return 'Passport confirmation box not ticked.' 844 #if len(self.errors) > 0:845 # return 'Form has errors.'846 800 return False 847 801 848 802 @grok.action('Save') 849 803 def save(self, **data): 850 #if self.context.locked:851 # self.emitLockMessage()852 # return853 804 self.applyData(self.context, **data) 854 805 self.context._p_changed = True … … 858 809 @grok.action('Final Submit') 859 810 def finalsubmit(self, **data): 860 #if self.context.locked:861 # self.emitLockMessage()862 # return863 811 self.applyData(self.context, **data) 864 812 self.context._p_changed = True … … 897 845 # A filename chooser turns a context into a filename suitable 898 846 # for file storage. 899 chooser = IFileStoreNameChooser(self.context) 900 file_id = chooser.chooseName() 901 image = getUtility(IExtFileStore).getFile(file_id) 847 image = getUtility(IExtFileStore).getFileByContext(self.context) 902 848 self.response.setHeader( 903 849 'Content-Type', 'image/jpeg')
Note: See TracChangeset for help on using the changeset viewer.