Changeset 16165 for main/kofacustom.iuokada/trunk/src/kofacustom
- Timestamp:
- 14 Jul 2020, 14:19:29 (4 years ago)
- Location:
- main/kofacustom.iuokada/trunk/src/kofacustom/iuokada/applicants
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
main/kofacustom.iuokada/trunk/src/kofacustom/iuokada/applicants/browser.py
r16142 r16165 124 124 125 125 TRANS_SHORT_OMIT_FIELDS = TRANS_OMIT_FIELDS + ( 126 'date_of_birth',126 #'date_of_birth', 127 127 'sex', 128 128 'nationality', 129 'entry_mode',130 'entry_session',129 #'entry_mode', 130 #'entry_session', 131 131 'end_session', 132 'course_studied',133 'course_changed',134 'change_level',132 #'course_studied', 133 #'course_changed', 134 #'change_level', 135 135 ) 136 136 … … 158 158 @property 159 159 def form_fields(self): 160 if self.target is not None and self.target == 't ransfull':160 if self.target is not None and self.target == 'tscf': 161 161 form_fields = grok.AutoFields(ITranscriptApplicant) 162 162 for field in TRANS_OMIT_FIELDS: 163 163 form_fields = form_fields.omit(field) 164 164 form_fields['dispatch_address'].custom_widget = BytesDisplayWidget 165 form_fields['perm_address'].custom_widget = BytesDisplayWidget166 return form_fields 167 if self.target is not None and self.target == 't ransshort':165 #form_fields['perm_address'].custom_widget = BytesDisplayWidget 166 return form_fields 167 if self.target is not None and self.target == 'tscs': 168 168 form_fields = grok.AutoFields(ITranscriptApplicant) 169 169 for field in TRANS_SHORT_OMIT_FIELDS: 170 170 form_fields = form_fields.omit(field) 171 171 form_fields['dispatch_address'].custom_widget = BytesDisplayWidget 172 form_fields['perm_address'].custom_widget = BytesDisplayWidget172 #form_fields['perm_address'].custom_widget = BytesDisplayWidget 173 173 return form_fields 174 174 if self.target is not None and self.target.startswith('pg'): … … 192 192 return form_fields 193 193 194 def getCerts(view, coursex): 195 yield(dict(code='', title='--', selected='')) 196 appcatcertificatesource = AppCatCertificateSource().factory 197 for cert in appcatcertificatesource.getValues(view.context): 198 selected = '' 199 course = getattr(view.context, coursex) 200 if course is not None and course.code == cert.code: 201 selected = 'selected' 202 title = appcatcertificatesource.getTitle(view.context, cert) 203 yield(dict(code=cert.code, title=title, selected=selected)) 204 205 def saveCourses(view, changed_fields=[]): 206 """In custom packages we needed to customize the certificate 207 select widget. We just save course1 and course2 if these customized 208 fields appear in the form. 209 """ 210 form = view.request.form 211 course1 = form.get('custom.course1', None) 212 course2 = form.get('custom.course2', None) 213 cat = queryUtility(ICatalog, name='certificates_catalog') 214 if course1: 215 results = list( 216 cat.searchResults(code=(course1, course1))) 217 view.context.course1 = results[0] 218 changed_fields.append('course1') 219 if course2: 220 results = list( 221 cat.searchResults(code=(course2, course2))) 222 view.context.course2 = results[0] 223 changed_fields.append('course2') 224 return changed_fields 225 226 def display_fileupload(view, filename): 227 if view.target.startswith('tsc'): 228 return False 229 if filename[1] == 'res_stat.pdf': 230 if view.context.subtype != 'transfer': 231 return False 232 if filename[1] == 'jamb.pdf' \ 233 and view.target is not None \ 234 and view.target.startswith('pg'): 235 return False 236 if filename[1] == 'nysc.pdf' \ 237 and view.target is not None \ 238 and not view.target.startswith('pg'): 239 return False 240 return True 241 194 242 class CustomApplicantManageFormPage(NigeriaApplicantManageFormPage): 195 243 """A full edit view for applicant data. … … 197 245 198 246 def getCerts(self, coursex): 199 yield(dict(code='', title='--', selected='')) 200 appcatcertificatesource = AppCatCertificateSource().factory 201 for cert in appcatcertificatesource.getValues(self.context): 202 selected = '' 203 course = getattr(self.context, coursex) 204 if course is not None and course.code == cert.code: 205 selected = 'selected' 206 title = appcatcertificatesource.getTitle(self.context, cert) 207 yield(dict(code=cert.code, title=title, selected=selected)) 247 return getCerts(self, coursex) 208 248 209 249 def saveCourses(self, changed_fields): 210 """In custom packages we needed to customize the certificate 211 select widget. We just save course1 and course2 if these customized 212 fields appear in the form. 213 """ 214 form = self.request.form 215 course1 = form.get('custom.course1', None) 216 course2 = form.get('custom.course2', None) 217 cat = queryUtility(ICatalog, name='certificates_catalog') 218 if course1: 219 results = list( 220 cat.searchResults(code=(course1, course1))) 221 self.context.course1 = results[0] 222 changed_fields.append('course1') 223 if course2: 224 results = list( 225 cat.searchResults(code=(course2, course2))) 226 self.context.course2 = results[0] 227 changed_fields.append('course2') 228 return changed_fields 250 return saveCourses(self, changed_fields) 251 252 def display_fileupload(self, filename): 253 return display_fileupload(self, filename) 229 254 230 255 @property … … 236 261 @property 237 262 def form_fields(self): 238 if self.target is not None and self.target == 'transfull': 263 self.course_selector = False 264 if self.target is not None and self.target == 'tscf': 239 265 form_fields = grok.AutoFields(ITranscriptApplicant) 240 266 for field in TRANS_OMIT_FIELDS: 241 267 form_fields = form_fields.omit(field) 242 268 return form_fields 243 if self.target is not None and self.target == 't ransshort':269 if self.target is not None and self.target == 'tscs': 244 270 form_fields = grok.AutoFields(ITranscriptApplicant) 245 271 for field in TRANS_SHORT_OMIT_FIELDS: 246 272 form_fields = form_fields.omit(field) 247 273 return form_fields 274 self.course_selector = True 248 275 if self.target is not None and self.target.startswith('pg'): 249 276 form_fields = grok.AutoFields(ICustomPGApplicant) … … 263 290 264 291 def getCerts(self, coursex): 265 yield(dict(code='', title='--', selected='')) 266 appcatcertificatesource = AppCatCertificateSource().factory 267 for cert in appcatcertificatesource.getValues(self.context): 268 selected = '' 269 course = getattr(self.context, coursex) 270 if course is not None and course.code == cert.code: 271 selected = 'selected' 272 title = appcatcertificatesource.getTitle(self.context, cert) 273 yield(dict(code=cert.code, title=title, selected=selected)) 292 return getCerts(self, coursex) 274 293 275 294 def saveCourses(self): 276 """In custom packages we needed to customize the certificate 277 select widget. We just save course1 and course2 if these customized 278 fields appear in the form. 279 """ 280 form = self.request.form 281 course1 = form.get('custom.course1', None) 282 course2 = form.get('custom.course2', None) 283 cat = queryUtility(ICatalog, name='certificates_catalog') 284 if course1: 285 results = list( 286 cat.searchResults(code=(course1, course1))) 287 self.context.course1 = results[0] 288 if course2: 289 results = list( 290 cat.searchResults(code=(course2, course2))) 291 self.context.course2 = results[0] 292 return 295 return saveCourses(self) 293 296 294 297 def display_fileupload(self, filename): 295 if filename[1] == 'res_stat.pdf': 296 if self.context.subtype != 'transfer': 297 return False 298 if filename[1] == 'jamb.pdf' \ 299 and self.target is not None \ 300 and self.target.startswith('pg'): 301 return False 302 if filename[1] == 'nysc.pdf' \ 303 and self.target is not None \ 304 and not self.target.startswith('pg'): 305 return False 306 return True 298 return display_fileupload(self, filename) 307 299 308 300 def dataNotComplete(self, data): … … 320 312 @property 321 313 def form_fields(self): 322 if self.target is not None and self.target == 'transfull': 314 self.course_selector = False 315 if self.target is not None and self.target == 'tscf': 323 316 form_fields = grok.AutoFields(ITranscriptApplicant) 324 317 for field in TRANS_OMIT_FIELDS: 325 318 form_fields = form_fields.omit(field) 326 319 return form_fields 327 if self.target is not None and self.target == 't ransshort':320 if self.target is not None and self.target == 'tscs': 328 321 form_fields = grok.AutoFields(ITranscriptApplicant) 329 322 for field in TRANS_SHORT_OMIT_FIELDS: 330 323 form_fields = form_fields.omit(field) 331 324 return form_fields 325 self.course_selector = True 332 326 if self.target is not None and self.target.startswith('pg'): 333 327 form_fields = grok.AutoFields(ICustomPGApplicantEdit) -
main/kofacustom.iuokada/trunk/src/kofacustom/iuokada/applicants/browser_templates/applicanteditpage.pt
r16076 r16165 22 22 <tbody> 23 23 <tal:widgets content="structure provider:widgets" /> 24 24 <tal:course_selector condition="view/course_selector"> 25 25 <tr> 26 26 <td class="separator" colspan="2"> … … 73 73 </tr> 74 74 <tr> 75 76 <tr> 77 <td class="separator" colspan="2"> 75 </tal:course_selector> 76 77 <tr> 78 <td class="separator" colspan="2" 79 tal:condition="python: not view.target.startswith('tsc')"> 78 80 File Uploads 79 81 </td> 80 82 </tr> 81 82 83 <tr tal:condition="python: context.__parent__.with_picture"> 83 84 <td class="fieldname" i18n:translate=""> -
main/kofacustom.iuokada/trunk/src/kofacustom/iuokada/applicants/interfaces.py
r16147 r16165 21 21 22 22 from zope import schema 23 from zope.component import getUtility 24 from zope.catalog.interfaces import ICatalog 23 25 from zc.sourcefactory.basic import BasicSourceFactory 24 26 from waeup.kofa.applicants.interfaces import ( … … 111 113 DESTINATION_COST[value][1]) 112 114 115 class TranscriptCertificateSource(CertificateSource): 116 """Include Department and Faculty in Title. 117 """ 118 def getValues(self, context): 119 catalog = getUtility(ICatalog, name='certificates_catalog') 120 resultset = catalog.searchResults(code=(None, None)) 121 resultlist = sorted(resultset, key=lambda 122 value: value.__parent__.__parent__.__parent__.code + 123 value.__parent__.__parent__.code + 124 value.code) 125 return resultlist 126 127 def getTitle(self, context, value): 128 """ 129 """ 130 try: title = "%s / %s / %s (%s)" % ( 131 value.__parent__.__parent__.__parent__.title, 132 value.__parent__.__parent__.title, 133 value.title, value.code) 134 except AttributeError: 135 title = "NA / %s (%s)" % (value.title, value.code) 136 return title 137 113 138 class ICustomUGApplicant(IApplicantBaseData): 114 139 """An undergraduate applicant. … … 415 440 ) 416 441 417 #student_id = schema.TextLine(418 # title = _(u'Kofa Student Id'),419 # required = False,420 # readonly = False,421 # )422 423 #reg_number = schema.TextLine(424 # title = _(u'Registration Number'),425 # readonly = False,426 # required = False,427 # )428 429 442 matric_number = schema.TextLine( 430 443 title = _(u'Matriculation Number'), … … 448 461 ) 449 462 450 date_of_birth = FormattedDate(451 title = _(u'Date of Birth'),452 required = False,453 #date_format = u'%d/%m/%Y', # Use grok-instance-wide default454 show_year = True,455 )463 #date_of_birth = FormattedDate( 464 # title = _(u'Date of Birth'), 465 # required = False, 466 # #date_format = u'%d/%m/%Y', # Use grok-instance-wide default 467 # show_year = True, 468 # ) 456 469 457 470 sex = schema.Choice( … … 461 474 ) 462 475 463 nationality = schema.Choice(464 vocabulary = nats_vocab,465 title = _(u'Nationality'),466 required = False,467 )476 #nationality = schema.Choice( 477 # vocabulary = nats_vocab, 478 # title = _(u'Nationality'), 479 # required = False, 480 # ) 468 481 469 482 email = schema.ASCIILine( … … 473 486 ) 474 487 475 phone = PhoneNumber(476 title = _(u'Phone'),477 description = u'',478 required = False,479 )480 481 perm_address = schema.Text(482 title = _(u'Current Local Address'),483 required = False,484 readonly = False,485 )488 #phone = PhoneNumber( 489 # title = _(u'Phone'), 490 # description = u'', 491 # required = False, 492 # ) 493 494 #perm_address = schema.Text( 495 # title = _(u'Current Local Address'), 496 # required = False, 497 # readonly = False, 498 # ) 486 499 487 500 dispatch_address = schema.Text( … … 499 512 ) 500 513 501 entry_mode = schema.Choice( 502 title = _(u'Entry Mode'), 503 source = StudyModeSource(), 504 required = False, 505 readonly = False, 506 ) 507 508 entry_session = schema.Choice( 509 title = _(u'Entry Session'), 514 #entry_mode = schema.Choice( 515 # title = _(u'Entry Mode'), 516 # source = StudyModeSource(), 517 # required = False, 518 # readonly = False, 519 # ) 520 521 #entry_session = schema.Choice( 522 # title = _(u'Entry Session'), 523 # source = academic_sessions_vocab, 524 # required = False, 525 # readonly = False, 526 # ) 527 528 end_session = schema.Choice( 529 title = _(u'Academic Session of Graduation'), 510 530 source = academic_sessions_vocab, 511 531 required = False, … … 513 533 ) 514 534 515 end_session = schema.Choice(516 title = _(u'End Session'),517 source = academic_sessions_vocab,518 required = False,519 readonly = False,520 )521 522 535 course_studied = schema.Choice( 523 title = _(u'Course of Study / Degree'), 524 source = CertificateSource(), 525 required = False, 526 readonly = False, 527 ) 528 529 course_changed = schema.Choice( 530 title = _(u'Change of Study Course'), 531 description = u'If yes, select previous course of study.', 532 source = CertificateSource(), 533 readonly = False, 534 required = False, 535 ) 536 537 change_level = schema.Choice( 538 title = _(u'Change Level'), 539 description = u'If yes, select level at which you changed course of study.', 540 source = StudyLevelSource(), 541 required = False, 542 readonly = False, 543 ) 536 title = _(u'Course of Study'), 537 source = TranscriptCertificateSource(), 538 description = u'Faculty / Department / Course', 539 required = False, 540 readonly = False, 541 ) 542 543 #course_changed = schema.Choice( 544 # title = _(u'Change of Study Course'), 545 # description = u'If yes, select previous course of study.', 546 # source = CertificateSource(), 547 # readonly = False, 548 # required = False, 549 # ) 550 551 #change_level = schema.Choice( 552 # title = _(u'Change Level'), 553 # description = u'If yes, select level at which you changed course of study.', 554 # source = StudyLevelSource(), 555 # required = False, 556 # readonly = False, 557 # ) 544 558 545 559 no_copies = schema.Choice( -
main/kofacustom.iuokada/trunk/src/kofacustom/iuokada/applicants/utils.py
r16142 r16165 58 58 'pg': ['Postgraduate Programmes', 'PG'], 59 59 'ug': ['Undergraduate Programmes', 'UG'], 60 't ransfull': ['Transcript Application (without student record)', 'TRF'],61 't ransshort': ['Transcript Application (with student record)', 'TRS'],60 'tscf': ['Transcript Application (without student record)', 'TRF'], 61 'tscs': ['Transcript Application (with student record)', 'TRS'], 62 62 } 63 63
Note: See TracChangeset for help on using the changeset viewer.