Changeset 7347 for main/waeup.sirp/trunk/src/waeup/sirp
- Timestamp:
- 14 Dec 2011, 22:34:02 (13 years ago)
- Location:
- main/waeup.sirp/trunk/src/waeup/sirp/applicants
- Files:
-
- 2 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/applicants/__init__.py
r7341 r7347 10 10 ApplicantsRoot, get_applicant_data, application_exists, 11 11 ) 12 from waeup.sirp.applicants.dynamicroles import ( 13 ApplicantPrincipalRoleManager,) 12 14 13 15 __all__ = [ … … 16 18 'ApplicantImageNameChooser', 17 19 'ApplicantImageStoreHandler', 20 'ApplicantPrincipalRoleManager', 18 21 'ApplicantsContainer', 19 22 'ApplicantsRoot', -
main/waeup.sirp/trunk/src/waeup/sirp/applicants/applicant.py
r7344 r7347 93 93 return False, 'Registration Number exists.' 94 94 # Has the course_admitted field been properly filled? 95 code = self.course_admitted.get('code') 96 if code: 97 catalog = getUtility(ICatalog, name='certificates_catalog') 98 cert = [i for i in catalog.searchResults(code=(code,code))][0] 99 else: 95 if self.course_admitted is None: 100 96 return False, 'No course admitted provided.' 101 97 # Add student object … … 117 113 student.phone = self.phone 118 114 # Save the certificate 119 student['studycourse'].certificate = cert115 student['studycourse'].certificate = self.course_admitted 120 116 # Create StudentApplication object ... 121 117 application = createObject(u'waeup.StudentApplication') -
main/waeup.sirp/trunk/src/waeup/sirp/applicants/browser.py
r7341 r7347 438 438 grok.template('applicantdisplaypage') 439 439 form_fields = grok.AutoFields(IApplicant).omit( 440 'locked', 441 'password') 440 'locked', 'course_admitted', 'password') 442 441 form_fields['date_of_birth'].custom_widget = FriendlyDateDisplayWidget('le') 443 442 label = 'Applicant' … … 469 468 container_title, self.context.application_number) 470 469 471 def getDepartmentAdmitted(self): 472 course_admitted = getattr(self.context,'course_admitted',None) 473 if course_admitted: 474 return course_admitted['dep'] 475 476 def getFacultyAdmitted(self): 477 course_admitted = getattr(self.context,'course_admitted',None) 478 if course_admitted: 479 return course_admitted['fac'] 470 def getCourseAdmitted(self): 471 """Return link, title and code in html format to the certificate 472 admitted. 473 """ 474 course_admitted = self.context.course_admitted 475 if ICertificate.providedBy(course_admitted): 476 url = self.url(course_admitted) 477 title = course_admitted.title 478 code = course_admitted.code 479 return '<a href="%s">%s - %s</a>' %(url,code,title) 480 return '' 480 481 481 482 class ApplicantBaseDisplayFormPage(ApplicantDisplayFormPage): … … 672 673 grok.require('waeup.viewApplication') 673 674 form_fields = grok.AutoFields(IApplicant).omit( 674 'locked', 675 ) 675 'locked', 'course_admitted') 676 676 form_fields['date_of_birth'].custom_widget = FriendlyDateDisplayWidget('le') 677 677 prefix = 'form' … … 683 683 container_title, self.context.application_number) 684 684 685 def get DepartmentAdmitted(self):686 course_admitted = getattr(self.context,'course_admitted',None)687 if course_admitted:688 return course_admitted['dep']689 690 def getFacultyAdmitted(self):691 course_admitted = getattr(self.context,'course_admitted',None)692 if course_admitted:693 return course_admitted['fac']694 685 def getCourseAdmitted(self): 686 """Return title and code in html format to the certificate 687 admitted. 688 """ 689 course_admitted = self.context.course_admitted 690 if ICertificate.providedBy(course_admitted): 691 title = course_admitted.title 692 code = course_admitted.code 693 return '%s - %s' %(code,title) 694 return '' 695 695 696 696 def setUpWidgets(self, ignore_request=False): … … 755 755 f_text = Paragraph(f_text, style["Normal"]) 756 756 data.append([f_label,f_text]) 757 #f_label = '<font size=12>Admitted Course of Study:</font>' 758 #f_text = '<font size=12>%s</font>' % self.getCourseAdmitted() 759 #f_label = Paragraph(f_label, style["Normal"]) 760 #f_text = Paragraph(f_text, style["Normal"]) 761 #data.append([f_label,f_text]) 762 763 f_label = '<font size=12>Department:</font>' 764 f_text = '<font size=12>%s</font>' % self.getDepartmentAdmitted() 757 course_admitted = self.getCourseAdmitted() 758 f_label = '<font size=12>Admitted Course of Study:</font>' 759 f_text = '<font size=12>%s</font>' % course_admitted 765 760 f_label = Paragraph(f_label, style["Normal"]) 766 761 f_text = Paragraph(f_text, style["Normal"]) 767 762 data.append([f_label,f_text]) 768 763 769 f_label = '<font size=12>Faculty:</font>' 770 f_text = '<font size=12>%s</font>' % self.getFacultyAdmitted() 771 f_label = Paragraph(f_label, style["Normal"]) 772 f_text = Paragraph(f_text, style["Normal"]) 773 data.append([f_label,f_text]) 764 course_admitted = self.context.course_admitted 765 if ICertificate.providedBy(course_admitted): 766 f_label = '<font size=12>Department:</font>' 767 f_text = '<font size=12>%s</font>' % ( 768 course_admitted.__parent__.__parent__.longtitle()) 769 f_label = Paragraph(f_label, style["Normal"]) 770 f_text = Paragraph(f_text, style["Normal"]) 771 data.append([f_label,f_text]) 772 773 f_label = '<font size=12>Faculty:</font>' 774 f_text = '<font size=12>%s</font>' % ( 775 course_admitted.__parent__.__parent__.__parent__.longtitle()) 776 f_label = Paragraph(f_label, style["Normal"]) 777 f_text = Paragraph(f_text, style["Normal"]) 778 data.append([f_label,f_text]) 774 779 775 780 # Create table -
main/waeup.sirp/trunk/src/waeup/sirp/applicants/browser_templates/applicantdisplaypage.pt
r7341 r7347 27 27 <tr> 28 28 <td class="fieldname"> 29 Department:29 Admitted Course of Study: 30 30 </td> 31 31 <td> 32 <span tal:replace="view/getDepartmentAdmitted" /> 33 </td> 34 </tr> 35 <tr> 36 <td class="fieldname"> 37 Faculty: 38 </td> 39 <td> 40 <span tal:replace="view/getFacultyAdmitted" /> 32 <span tal:replace="structure view/getCourseAdmitted" /> 41 33 </td> 42 34 </tr> -
main/waeup.sirp/trunk/src/waeup/sirp/applicants/interfaces.py
r7341 r7347 32 32 ISIRPObject, year_range, validate_email, academic_sessions_vocab) 33 33 from waeup.sirp.university.vocabularies import application_categories 34 from waeup.sirp.students.vocabularies import lgas_vocab, GenderSource 34 from waeup.sirp.students.vocabularies import ( 35 lgas_vocab, CertificateSource, GenderSource, 36 ) 35 37 from waeup.sirp.applicants.vocabularies import ( 36 38 application_types_vocab, application_pins_vocab, 37 AppCatCertificate TitleSource, CertificateTitleSource39 AppCatCertificateSource, 38 40 ) 39 41 from waeup.sirp.payments.interfaces import IOnlinePayment … … 343 345 course1 = schema.Choice( 344 346 title = u'1st Choice Course of Study', 345 source = Certificate TitleSource(),347 source = CertificateSource(), 346 348 required = True, 347 349 ) 348 350 course2 = schema.Choice( 349 351 title = u'2nd Choice Course of Study', 350 source = Certificate TitleSource(),352 source = CertificateSource(), 351 353 required = False, 352 354 ) … … 363 365 required = False, 364 366 ) 367 course_admitted = schema.Choice( 368 title = u'Admitted Course of Study', 369 source = CertificateSource(), 370 default = None, 371 required = False, 372 ) 365 373 notice = schema.Text( 366 374 title = u'Notice', 367 required = False,368 )369 course_admitted = schema.Choice(370 title = u'Admitted Course of Study',371 source = CertificateTitleSource(),372 default = None,373 375 required = False, 374 376 ) … … 423 425 course1 = schema.Choice( 424 426 title = u'1st Choice Course of Study', 425 source = AppCatCertificate TitleSource(),427 source = AppCatCertificateSource(), 426 428 required = True, 427 429 ) 428 430 course2 = schema.Choice( 429 431 title = u'2nd Choice Course of Study', 430 source = AppCatCertificate TitleSource(),432 source = AppCatCertificateSource(), 431 433 required = False, 432 434 ) … … 443 445 course_admitted = schema.Choice( 444 446 title = u'Admitted Course of Study', 445 source = Certificate TitleSource(),447 source = CertificateSource(), 446 448 default = None, 447 449 required = False, -
main/waeup.sirp/trunk/src/waeup/sirp/applicants/vocabularies.py
r7341 r7347 21 21 from zope.catalog.interfaces import ICatalog 22 22 from waeup.sirp.interfaces import SimpleSIRPVocabulary 23 from zc.sourcefactory.contextual import BasicContextualSourceFactory23 from waeup.sirp.students.vocabularies import CertificateSource 24 24 25 25 #: Types of applications we support. … … 44 44 *[(u"%s (%s)" % (x[2],x[0]),x[2]) for x in APPLICATION_TYPES]) 45 45 46 class CertificateTitleSource(BasicContextualSourceFactory):47 """A certificate title source delivers all certificates titles provided48 in the portal.49 """50 def getValues(self, context):51 catalog = getUtility(ICatalog, name='certificates_catalog')52 certs = list(catalog.searchResults(code=('', 'z*')))53 certs = [dict(54 code = i.code,55 title = i.title,56 dep = i.__parent__.__parent__.longtitle(),57 fac = i.__parent__.__parent__.__parent__.longtitle()58 ) for i in certs]59 return sorted(certs, key=lambda value: value['code'])60 46 61 def getToken(self, context, value): 62 return value['code'] 63 64 def getTitle(self, context, value): 65 return "%s - %s" % (value['code'], value['title'][:64]) 66 67 class AppCatCertificateTitleSource(CertificateTitleSource): 68 """An application certificate source delivers all course titles which belong to 47 class AppCatCertificateSource(CertificateSource): 48 """An application certificate source delivers all courses which belong to 69 49 a certain application_category. 70 50 """ … … 72 52 appcat = context.__parent__.application_category 73 53 catalog = getUtility(ICatalog, name='certificates_catalog') 74 certs = list(catalog.searchResults(code=('', 'z*'), 75 application_category=(appcat,appcat))) 76 certs = [dict( 77 code = i.code, 78 title = i.title, 79 dep = i.__parent__.__parent__.longtitle(), 80 fac = i.__parent__.__parent__.__parent__.longtitle() 81 ) for i in certs] 82 return sorted(certs, key=lambda value: value['code']) 83 84 54 return sorted(list( 55 catalog.searchResults( 56 code=('', 'z*'), 57 application_category=(appcat,appcat))), 58 key=lambda value: value.code)
Note: See TracChangeset for help on using the changeset viewer.