Changeset 10350
- Timestamp:
- 22 Jun 2013, 21:39:00 (11 years ago)
- Location:
- main/waeup.imostate/src/waeup/imostate
- Files:
-
- 1 deleted
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.imostate/src/waeup/imostate/applicants/applicant.py
r10340 r10350 25 25 from kofacustom.nigeria.applicants.applicant import NigeriaApplicant 26 26 from waeup.imostate.applicants.interfaces import( 27 ICustomApplicant, ICustomUGApplicantEdit , ICustomPGApplicantEdit, IPUTMEApplicantEdit)27 ICustomApplicant, ICustomUGApplicantEdit) 28 28 29 29 @grok.subscribe(ICustomApplicant, grok.IObjectRemovedEvent) … … 39 39 class CustomApplicant(NigeriaApplicant): 40 40 41 grok.implements(ICustomApplicant, ICustomUGApplicantEdit, 42 ICustomPGApplicantEdit, IPUTMEApplicantEdit) 41 grok.implements(ICustomApplicant, ICustomUGApplicantEdit) 43 42 grok.provides(ICustomApplicant) 44 43 45 @property46 def low_jamb_score(self):47 jamb_score = getattr(self, 'jamb_score', None)48 course1 = getattr(self, 'course1', None)49 limit = getattr(course1, 'custom_float_1', None)50 if None in (jamb_score, limit):51 return False52 if jamb_score < limit:53 return True54 return False55 44 56 45 # Set all attributes of CustomApplicant required in ICustomApplicant as field -
main/waeup.imostate/src/waeup/imostate/applicants/browser.py
r10340 r10350 28 28 ICustomApplicant, 29 29 ICustomUGApplicant, 30 ICustomPGApplicant,31 ICustomPGApplicantEdit,32 30 ICustomUGApplicantEdit, 33 UG_OMIT_DISPLAY_FIELDS,34 UG_OMIT_PDF_FIELDS,35 UG_OMIT_MANAGE_FIELDS,36 UG_OMIT_EDIT_FIELDS,37 PG_OMIT_DISPLAY_FIELDS,38 PG_OMIT_PDF_FIELDS,39 PG_OMIT_MANAGE_FIELDS,40 PG_OMIT_EDIT_FIELDS,41 PUTME_OMIT_EDIT_FIELDS,42 PUTME_OMIT_DISPLAY_FIELDS,43 PUTME_OMIT_PDF_FIELDS,44 PUTME_OMIT_MANAGE_FIELDS,45 PUTME_OMIT_EDIT_FIELDS,46 31 ) 47 32 from waeup.imostate.interfaces import MessageFactory as _ … … 102 87 @property 103 88 def form_fields(self): 104 if self.target is not None and self.target.startswith('pg'): 105 form_fields = grok.AutoFields(ICustomPGApplicant) 106 for field in PG_OMIT_DISPLAY_FIELDS: 107 form_fields = form_fields.omit(field) 108 else: 109 form_fields = grok.AutoFields(ICustomUGApplicant) 110 for field in UG_OMIT_DISPLAY_FIELDS: 111 form_fields = form_fields.omit(field) 89 form_fields = grok.AutoFields(ICustomUGApplicant) 112 90 if form_fields.get('perm_address', None): 113 91 form_fields['perm_address'].custom_widget = BytesDisplayWidget … … 121 99 if not getattr(self.context, 'screening_date'): 122 100 form_fields = form_fields.omit('screening_date') 123 if not self.context.low_jamb_score:124 form_fields = form_fields.omit('course2')125 101 return form_fields 126 102 … … 136 112 @property 137 113 def form_fields(self): 138 if self.target is not None and self.target.startswith('pg'): 139 form_fields = grok.AutoFields(ICustomPGApplicant) 140 for field in PG_OMIT_PDF_FIELDS: 141 form_fields = form_fields.omit(field) 142 elif self.target is not None and self.target.startswith('putme'): 143 form_fields = grok.AutoFields(ICustomUGApplicant) 144 if self._reduced_slip(): 145 for field in PUTME_OMIT_RESULT_SLIP_FIELDS: 146 form_fields = form_fields.omit(field) 147 else: 148 form_fields = grok.AutoFields(ICustomUGApplicant) 149 for field in UG_OMIT_PDF_FIELDS: 150 form_fields = form_fields.omit(field) 114 form_fields = grok.AutoFields(ICustomUGApplicant) 151 115 if not getattr(self.context, 'student_id'): 152 116 form_fields = form_fields.omit('student_id') … … 157 121 if not getattr(self.context, 'screening_date'): 158 122 form_fields = form_fields.omit('screening_date') 159 if not self.context.low_jamb_score:160 form_fields = form_fields.omit('course2')161 123 return form_fields 162 124 … … 168 130 @property 169 131 def form_fields(self): 170 if self.target is not None and self.target.startswith('pg'): 171 form_fields = grok.AutoFields(ICustomPGApplicant) 172 for field in PG_OMIT_MANAGE_FIELDS: 173 form_fields = form_fields.omit(field) 174 elif self.target is not None and self.target.startswith('putme'): 175 form_fields = grok.AutoFields(ICustomUGApplicant) 176 for field in PUTME_OMIT_MANAGE_FIELDS: 177 form_fields = form_fields.omit(field) 178 else: 179 form_fields = grok.AutoFields(ICustomUGApplicant) 180 for field in UG_OMIT_MANAGE_FIELDS: 181 form_fields = form_fields.omit(field) 132 form_fields = grok.AutoFields(ICustomUGApplicant) 182 133 form_fields['student_id'].for_display = True 183 134 form_fields['applicant_id'].for_display = True … … 223 174 @property 224 175 def form_fields(self): 225 if self.target is not None and self.target.startswith('pg'): 226 form_fields = grok.AutoFields(ICustomPGApplicantEdit) 227 for field in PG_OMIT_EDIT_FIELDS: 228 form_fields = form_fields.omit(field) 229 elif self.target is not None and self.target.startswith('putme'): 230 form_fields = grok.AutoFields(ICustomUGApplicantEdit) 231 for field in PUTME_OMIT_EDIT_FIELDS: 232 form_fields = form_fields.omit(field) 233 else: 234 form_fields = grok.AutoFields(ICustomUGApplicantEdit) 235 for field in UG_OMIT_EDIT_FIELDS: 236 form_fields = form_fields.omit(field) 176 form_fields = grok.AutoFields(ICustomUGApplicantEdit) 237 177 form_fields['applicant_id'].for_display = True 238 178 form_fields['reg_number'].for_display = True 239 if not self.context.low_jamb_score:240 form_fields = form_fields.omit('course2')241 179 return form_fields 242 180 -
main/waeup.imostate/src/waeup/imostate/applicants/interfaces.py
r10340 r10350 32 32 INigeriaUGApplicantEdit, INigeriaPGApplicantEdit, 33 33 INigeriaApplicantUpdateByRegNo, 34 IPUTMEApplicantEdit,35 OMIT_DISPLAY_FIELDS,36 UG_OMIT_DISPLAY_FIELDS,37 UG_OMIT_PDF_FIELDS,38 UG_OMIT_MANAGE_FIELDS,39 UG_OMIT_EDIT_FIELDS,40 PUTME_OMIT_EDIT_FIELDS,41 PUTME_OMIT_DISPLAY_FIELDS,42 PUTME_OMIT_PDF_FIELDS,43 PUTME_OMIT_MANAGE_FIELDS,44 PUTME_OMIT_FIELDS,45 #PUTME_OMIT_EDIT_FIELDS,46 34 ) 47 48 PUTME_OMIT_EDIT_FIELDS = UG_OMIT_EDIT_FIELDS + PUTME_OMIT_FIELDS + (49 'firstname', 'middlename', 'lastname', 'sex',50 'lga')51 52 PG_OMIT_DISPLAY_FIELDS = OMIT_DISPLAY_FIELDS + ('course2',)53 PG_OMIT_PDF_FIELDS = PG_OMIT_DISPLAY_FIELDS + ('phone',)54 PG_OMIT_MANAGE_FIELDS = ('course2',)55 PG_OMIT_EDIT_FIELDS = PG_OMIT_MANAGE_FIELDS + PG_OMIT_DISPLAY_FIELDS + (56 'student_id', 'notice',57 'screening_score', 'screening_venue',58 'screening_date',)59 35 60 36 from waeup.imostate.interfaces import MessageFactory as _ 61 37 62 class ICustomUGApplicant(I ApplicantBaseData):38 class ICustomUGApplicant(INigeriaUGApplicant): 63 39 """An undergraduate applicant. 64 40 … … 68 44 """ 69 45 70 nationality = schema.Choice( 71 source = nats_vocab, 72 title = _(u'Nationality'), 73 required = True, 74 ) 75 lga = schema.Choice( 76 source = LGASource(), 77 title = _(u'State/LGA (Nigerians only)'), 78 required = False, 79 ) 80 perm_address = schema.Text( 81 title = _(u'Permanent Address'), 82 required = False, 83 ) 84 course1 = schema.Choice( 85 title = _(u'1st Choice Course of Study'), 86 source = AppCatCertificateSource(), 87 required = True, 88 ) 89 course2 = schema.Choice( 90 title = _(u'Change of Course'), 91 source = AppCatCertificateSource(), 92 required = False, 93 ) 94 hq_type = schema.Choice( 95 title = _(u'Qualification Obtained'), 96 required = False, 97 readonly = False, 98 vocabulary = high_qual, 99 ) 100 hq_matric_no = schema.TextLine( 101 title = _(u'Former Matric Number'), 102 required = False, 103 readonly = False, 104 ) 105 hq_degree = schema.Choice( 106 title = _(u'Class of Degree'), 107 required = False, 108 readonly = False, 109 vocabulary = high_grade, 110 ) 111 hq_school = schema.TextLine( 112 title = _(u'Institution Attended'), 113 required = False, 114 readonly = False, 115 ) 116 hq_session = schema.TextLine( 117 title = _(u'Years Attended'), 118 required = False, 119 readonly = False, 120 ) 121 hq_disc = schema.TextLine( 122 title = _(u'Discipline'), 123 required = False, 124 readonly = False, 125 ) 126 jamb_subjects = schema.Text( 127 title = _(u'Subjects and Scores'), 128 required = False, 129 ) 130 jamb_score = schema.Int( 131 title = _(u'Total JAMB Score'), 132 required = False, 133 ) 134 notice = schema.Text( 135 title = _(u'Notice'), 136 required = False, 137 ) 138 screening_venue = schema.TextLine( 139 title = _(u'Screening Venue'), 140 required = False, 141 ) 142 screening_date = schema.TextLine( 143 title = _(u'Screening Date'), 144 required = False, 145 ) 146 screening_score = schema.Int( 147 title = _(u'Screening Score (%)'), 148 required = False, 149 ) 150 aggregate = schema.Int( 151 title = _(u'Aggregate Score (%)'), 152 description = _(u'(average of relative JAMB and PUTME scores)'), 153 required = False, 154 ) 155 result_uploaded = schema.Bool( 156 title = _(u'Result uploaded'), 157 default = False, 158 ) 159 student_id = schema.TextLine( 160 title = _(u'Student Id'), 161 required = False, 162 readonly = False, 163 ) 164 course_admitted = schema.Choice( 165 title = _(u'Admitted Course of Study'), 166 source = CertificateSource(), 167 required = False, 168 ) 169 locked = schema.Bool( 170 title = _(u'Form locked'), 171 default = False, 172 ) 173 174 @invariant 175 def second_choice(applicant): 176 if applicant.course1 == applicant.course2: 177 raise Invalid(_("2nd choice course must differ from 1st choice course.")) 178 179 class ICustomPGApplicant(IApplicantBaseData): 180 """A postgraduate applicant. 181 182 This interface defines the least common multiple of all fields 183 in pg application forms. In customized forms, fields can be excluded by 184 adding them to the PG_OMIT* tuples. 185 """ 186 187 nationality = schema.Choice( 188 source = nats_vocab, 189 title = _(u'Nationality'), 190 required = True, 191 ) 192 lga = schema.Choice( 193 source = LGASource(), 194 title = _(u'State/LGA (Nigerians only)'), 195 required = False, 196 ) 197 perm_address = schema.Text( 198 title = _(u'Permanent Address'), 199 required = False, 200 ) 201 hq_type = schema.Choice( 202 title = _(u'Qualification Obtained'), 203 required = False, 204 readonly = False, 205 vocabulary = high_qual, 206 ) 207 hq_matric_no = schema.TextLine( 208 title = _(u'Former Matric Number'), 209 required = False, 210 readonly = False, 211 ) 212 hq_degree = schema.Choice( 213 title = _(u'Class of Degree'), 214 required = False, 215 readonly = False, 216 vocabulary = high_grade, 217 ) 218 hq_school = schema.TextLine( 219 title = _(u'Institution Attended'), 220 required = False, 221 readonly = False, 222 ) 223 hq_session = schema.TextLine( 224 title = _(u'Years Attended'), 225 required = False, 226 readonly = False, 227 ) 228 hq_disc = schema.TextLine( 229 title = _(u'Discipline'), 230 required = False, 231 readonly = False, 232 ) 233 pp_school = schema.Choice( 234 title = _(u'Qualification Obtained'), 235 required = False, 236 readonly = False, 237 vocabulary = exam_types, 238 ) 239 course1 = schema.Choice( 240 title = _(u'Programme desired'), 241 source = AppCatCertificateSource(), 242 required = True, 243 ) 244 notice = schema.Text( 245 title = _(u'Notice'), 246 required = False, 247 readonly = False, 248 ) 249 #screening_venue = schema.TextLine( 250 # title = _(u'Screening Venue'), 251 # required = False, 252 # ) 253 #screening_date = schema.TextLine( 254 # title = _(u'Screening Date'), 255 # required = False, 256 # ) 257 #screening_score = schema.Int( 258 # title = _(u'Screening Score (%)'), 259 # required = False, 260 # ) 261 student_id = schema.TextLine( 262 title = _(u'Student Id'), 263 required = False, 264 readonly = False, 265 ) 266 course_admitted = schema.Choice( 267 title = _(u'Admitted Course of Study'), 268 source = CertificateSource(), 269 required = False, 270 readonly = False, 271 ) 272 locked = schema.Bool( 273 title = _(u'Form locked'), 274 default = False, 275 ) 276 277 class ICustomApplicant(ICustomUGApplicant, ICustomPGApplicant): 46 class ICustomApplicant(ICustomUGApplicant): 278 47 """An interface for both types of applicants. 279 48 … … 306 75 """ 307 76 308 course1 = schema.Choice(309 title = _(u'1st Choice Course of Study'),310 source = AppCatCertificateSource(),311 required = True,312 readonly = True,313 )314 315 course2 = schema.Choice(316 title = _(u'Change of Course'),317 description = _(318 u'Your JAMB score is lower than the requirement for your '319 '1st choice course of study, chose another course here.'),320 source = AppCatCertificateSource(),321 required = True,322 )323 324 class ICustomPGApplicantEdit(ICustomPGApplicant):325 """A postgraduate applicant interface for editing.326 327 Here we can repeat the fields from base data and set the328 `required` and `readonly` attributes to True to further restrict329 the data access. Or we can allow only certain certificates to be330 selected by choosing the appropriate source.331 332 We cannot omit fields here. This has to be done in the333 respective form page.334 """335 336 77 337 78 class ICustomApplicantOnlinePayment(INigeriaApplicantOnlinePayment): -
main/waeup.imostate/src/waeup/imostate/applicants/tests/test_browser.py
r10340 r10350 328 328 fd = storage.getFile(file_id) 329 329 self.assertTrue(fd is None) 330 331 def test_certificate_source(self):332 # We add a second 'alternative' certificate333 certificate = createObject('waeup.Certificate')334 certificate.code = 'CERT2'335 certificate.title = 'New Certificate'336 certificate.application_category = 'basic'337 self.app['faculties']['fac1']['dep1'].certificates.addCertificate(338 certificate)339 self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')340 self.browser.open(self.edit_path)341 self.assertFalse('course2' in self.browser.contents)342 self.certificate.custom_textline_1 = u'Maths, Physics'343 self.certificate.custom_float_1 = 50.0344 certificate.custom_textline_1 = u'German, Physics'345 certificate.custom_float_1 = 30.0346 notify(grok.ObjectModifiedEvent(certificate))347 self.browser.open(self.edit_path)348 # Score must be set and below the limit349 # of course1 to see course2 field350 self.applicant.jamb_score = 20351 self.browser.open(self.edit_path)352 self.assertTrue('course2' in self.browser.contents)353 # But 20 is not enough to select the alternative CERT2354 self.assertFalse(355 'value="CERT2">CERT2 - New Certificate'356 in self.browser.contents)357 self.applicant.jamb_score = 30358 self.browser.open(self.edit_path)359 # 30 is enough360 self.assertTrue('course2' in self.browser.contents)361 self.assertTrue(362 'value="CERT2">CERT2 - New Certificate [German, Physics, 30]</option>'363 in self.browser.contents)364 365 def test_low_jamb_score(self):366 self.login()367 self.assertFalse('<select id="form.course2" name="form.course2" size="1" >'368 in self.browser.contents)369 self.certificate.custom_textline_1 = u'Maths, Physics'370 self.certificate.custom_float_1 = 50.0371 self.applicant.jamb_score = 40372 self.browser.open(self.edit_path)373 self.assertTrue('<select id="form.course2" name="form.course2" size="1" >'374 in self.browser.contents) -
main/waeup.imostate/src/waeup/imostate/applicants/utils.py
r10340 r10350 33 33 'form.applicant_id': _(u'Base Data'), 34 34 'form.course1': _(u'Programmes/Courses Desired'), 35 'form.hq_type': _(u'Higher Education Record'),36 #'form.notice': _(u'Application Process Information'),37 'form.pp_school': _(u'Post Primary School Qualification'),38 'form.notice': _(u'Process Data'),39 'form.jamb_subjects': _(u'JAMB Data'),40 35 } 41 42 def filterCertificates(self, context, resultset):43 """Filter and sort certificates in AppCatCertificateSource.44 """45 certs = sorted(resultset, key=lambda value: value.code)46 if context.jamb_score is not None:47 resultlist = [cert for cert in certs48 if cert.custom_float_1 is None49 or context.jamb_score >= cert.custom_float_1]50 else:51 resultlist = certs52 curr_course = context.course153 if curr_course is not None and curr_course not in resultlist:54 # display also current course even if certificate has been removed55 # or does not meet requirement56 resultlist = [curr_course,] + resultlist57 return resultlist58 59 def getCertTitle(self, context, value):60 """Compose the titles in AppCatCertificateSource.61 """62 if None not in (getattr(value, 'custom_textline_1'),63 getattr(value, 'custom_float_1')):64 return "%s - %s [%s, %d]" % (65 value.code, value.title,66 value.custom_textline_1, value.custom_float_1)67 return "%s - %s" % (value.code, value.title) -
main/waeup.imostate/src/waeup/imostate/utils/utils.py
r10340 r10350 27 27 } 28 28 29 SPECIAL_HANDLING_DICT = { 30 'regular': 'Regular Hostel', 31 'blocked': 'Blocked Hostel', 32 'sse': 'SSE Hostel' 33 } 29 34 30 35 31 PAYMENT_CATEGORIES = { 36 'schoolfee': 'School Fee',37 'clearance': 'Acceptance Fee',38 'hostel_maintenance': 'Hostel Maintenance Fee',39 'block_h_maintenance': 'Block H Maintenance Fee (deprecated category)',40 'application': 'Application Fee'41 32 } 42 33 43 34 SELECTABLE_PAYMENT_CATEGORIES = { 44 'schoolfee': 'School Fee',45 'clearance': 'Acceptance Fee',46 'hostel_maintenance': 'Hostel Maintenance Fee',47 'application': 'Application Fee'48 35 }
Note: See TracChangeset for help on using the changeset viewer.