Changeset 8017 for main/waeup.custom/trunk/src
- Timestamp:
- 2 Apr 2012, 10:14:03 (13 years ago)
- Location:
- main/waeup.custom/trunk/src/waeup/custom/applicants
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.custom/trunk/src/waeup/custom/applicants/browser.py
r8012 r8017 24 24 from waeup.kofa.widgets.phonewidget import PhoneWidget 25 25 from waeup.kofa.applicants.browser import (ApplicantDisplayFormPage, 26 OnlinePaymentCallbackPage, ExportPDFPage, ApplicantManageFormPage) 26 OnlinePaymentCallbackPage, ExportPDFPage, 27 ApplicantManageFormPage, ApplicantEditFormPage) 27 28 from waeup.kofa.applicants.viewlets import RequestCallbackActionButton 28 from waeup.kofa.applicants.interfaces import IApplicant, IApplicantEdit 29 from waeup.custom.applicants.interfaces import IPGApplicant, IUGApplicant 29 from waeup.kofa.applicants.pdf import PDFApplicationSlip 30 #from waeup.kofa.applicants.interfaces import IApplicant, IApplicantEdit 31 from waeup.custom.applicants.interfaces import ( 32 IPGApplicant, IUGApplicant, IPGApplicantEdit, IUGApplicantEdit) 30 33 from waeup.custom.interfaces import MessageFactory as _ 31 34 … … 43 46 return 44 47 45 class ExportPDFPage(ExportPDFPage): 46 """Deliver a PDF slip of the context. 47 """ 48 grok.context(IApplicant) 49 grok.name('application_slip.pdf') 50 grok.require('waeup.viewApplication') 51 form_fields = grok.AutoFields(IApplicant).omit( 52 'locked', 'course_admitted') 53 form_fields['date_of_birth'].custom_widget = FriendlyDateDisplayWidget('le') 54 prefix = 'form' 48 class PDFApplicationSlip(PDFApplicationSlip): 55 49 50 @property 51 def form_fields(self): 52 target = getattr(self.context.__parent__, 'prefix', None) 53 if target is not None and target.startswith('pg'): 54 form_fields = grok.AutoFields(IPGApplicant).omit( 55 'locked', 'course_admitted') 56 else: 57 form_fields = grok.AutoFields(IUGApplicant).omit( 58 'locked', 'course_admitted') 59 form_fields[ 60 'date_of_birth'].custom_widget = FriendlyDateDisplayWidget('le') 61 return form_fields 56 62 57 63 class ApplicantDisplayFormPage(ApplicantDisplayFormPage): 64 """A display view for applicant data. 65 """ 58 66 59 67 @property … … 66 74 form_fields = grok.AutoFields(IUGApplicant).omit( 67 75 'locked', 'course_admitted', 'password') 68 form_fields['date_of_birth'].custom_widget = FriendlyDateDisplayWidget('le') 76 form_fields[ 77 'date_of_birth'].custom_widget = FriendlyDateDisplayWidget('le') 69 78 return form_fields 70 79 … … 72 81 """A full edit view for applicant data. 73 82 """ 74 grok.context(IApplicant) 75 grok.name('manage') 76 grok.require('waeup.manageApplication') 77 form_fields = grok.AutoFields(IApplicant) 78 form_fields['date_of_birth'].custom_widget = FriendlyDateWidget('le-year') 79 form_fields['student_id'].for_display = True 80 form_fields['applicant_id'].for_display = True 81 form_fields['phone'].custom_widget = PhoneWidget 82 grok.template('applicanteditpage') 83 manage_applications = True 84 pnav = 3 85 display_actions = [[_('Save'), _('Final Submit')], 86 [_('Add online payment ticket'),_('Remove selected tickets')]] 83 84 @property 85 def form_fields(self): 86 target = getattr(self.context.__parent__, 'prefix', None) 87 if target is not None and target.startswith('pg'): 88 form_fields = grok.AutoFields(IPGApplicant) 89 else: 90 form_fields = grok.AutoFields(IUGApplicant) 91 form_fields[ 92 'date_of_birth'].custom_widget = FriendlyDateWidget('le-year') 93 form_fields['phone'].custom_widget = PhoneWidget 94 form_fields['student_id'].for_display = True 95 form_fields['applicant_id'].for_display = True 96 form_fields['phone'].custom_widget = PhoneWidget 97 return form_fields 87 98 88 89 class ApplicantEditFormPage(ApplicantManageFormPage): 99 class ApplicantEditFormPage(ApplicantEditFormPage): 90 100 """An applicant-centered edit view for applicant data. 91 101 """ 92 grok.context(IApplicantEdit) 93 grok.name('edit') 94 grok.require('waeup.handleApplication') 95 form_fields = grok.AutoFields(IApplicantEdit).omit( 96 'locked', 'course_admitted', 'student_id', 97 'screening_score', 'reg_number' 98 ) 99 form_fields['date_of_birth'].custom_widget = FriendlyDateWidget('le-year') 100 form_fields['phone'].custom_widget = PhoneWidget 101 form_fields['applicant_id'].for_display = True 102 grok.template('applicanteditpage') 103 manage_applications = False 102 103 @property 104 def form_fields(self): 105 target = getattr(self.context.__parent__, 'prefix', None) 106 if target is not None and target.startswith('pg'): 107 form_fields = grok.AutoFields(IPGApplicantEdit).omit( 108 'locked', 'course_admitted', 'student_id', 109 'screening_score', 'reg_number' 110 ) 111 else: 112 form_fields = grok.AutoFields(IUGApplicantEdit).omit( 113 'locked', 'course_admitted', 'student_id', 114 'screening_score', 'reg_number' 115 ) 116 form_fields[ 117 'date_of_birth'].custom_widget = FriendlyDateWidget('le-year') 118 form_fields['phone'].custom_widget = PhoneWidget 119 form_fields['applicant_id'].for_display = True 120 return form_fields -
main/waeup.custom/trunk/src/waeup/custom/applicants/interfaces.py
r8012 r8017 44 44 """ 45 45 46 class IUGApplicantEdit(I ApplicantProcessData):46 class IUGApplicantEdit(IUGApplicant): 47 47 """An undergraduate applicant interface for editing. 48 48 … … 56 56 """ 57 57 58 class IPGApplicantEdit(I ApplicantProcessData):58 class IPGApplicantEdit(IPGApplicant): 59 59 """A postgraduate applicant interface for editing. 60 60 -
main/waeup.custom/trunk/src/waeup/custom/applicants/tests.py
r8012 r8017 105 105 % self.pgapplication_number) 106 106 self.browser.addHeader('Authorization', 'Basic mgr:mgrpw') 107 # The IPGApplicant interface is really used in all pages 107 108 self.browser.open(pgapplicant_path) 108 109 self.assertEqual(self.browser.headers['Status'], '200 Ok') 109 # The IPGApplicant interface is really used110 110 self.assertTrue('Employer' in self.browser.contents) 111 # If we move the applicant to the container, 112 # the Employer field disappears 111 self.browser.open(pgapplicant_path + '/manage') 112 self.assertEqual(self.browser.headers['Status'], '200 Ok') 113 self.assertTrue('Employer' in self.browser.contents) 114 self.browser.open(pgapplicant_path + '/edit') 115 self.assertEqual(self.browser.headers['Status'], '200 Ok') 116 self.assertTrue('Employer' in self.browser.contents) 117 self.browser.open(pgapplicant_path + '/application_slip.pdf') 118 self.assertEqual(self.browser.headers['Status'], '200 Ok') 119 # If we lool at the applicant in the ug container, 120 # the employer field doesn't appear 113 121 ugapplicant_path = ('http://localhost/app/applicants/app2011/%s' 114 122 % self.ugapplication_number) … … 116 124 self.browser.open(ugapplicant_path) 117 125 self.assertEqual(self.browser.headers['Status'], '200 Ok') 118 119 126 self.assertFalse('Employer' in self.browser.contents) 127 self.browser.open(ugapplicant_path + '/manage') 128 self.assertEqual(self.browser.headers['Status'], '200 Ok') 129 self.assertFalse('Employer' in self.browser.contents) 130 self.browser.open(ugapplicant_path + '/edit') 131 self.assertEqual(self.browser.headers['Status'], '200 Ok') 132 self.assertFalse('Employer' in self.browser.contents) 133 self.browser.open(ugapplicant_path + '/application_slip.pdf') 134 self.assertEqual(self.browser.headers['Status'], '200 Ok') 120 135 return
Note: See TracChangeset for help on using the changeset viewer.