Changeset 7341 for main/waeup.sirp/trunk/src/waeup/sirp/applicants
- Timestamp:
- 14 Dec 2011, 13:38:59 (13 years ago)
- Location:
- main/waeup.sirp/trunk/src/waeup/sirp/applicants
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/applicants/__init__.py
r7240 r7341 10 10 ApplicantsRoot, get_applicant_data, application_exists, 11 11 ) 12 from waeup.sirp.applicants.dynamicroles import (13 ApplicantPrincipalRoleManager,)14 12 15 13 __all__ = [ … … 18 16 'ApplicantImageNameChooser', 19 17 'ApplicantImageStoreHandler', 20 'ApplicantPrincipalRoleManager',21 18 'ApplicantsContainer', 22 19 'ApplicantsRoot', -
main/waeup.sirp/trunk/src/waeup/sirp/applicants/applicant.py
r7338 r7341 20 20 from grok import index 21 21 from zope.component.interfaces import IFactory 22 from zope.component import createObject 22 from zope.component import createObject, getUtility 23 from zope.catalog.interfaces import ICatalog 23 24 from zope.securitypolicy.interfaces import IPrincipalRoleManager 24 25 from zope.interface import implementedBy … … 31 32 from waeup.sirp.utils.helpers import attrs_to_fields, get_current_principal 32 33 from waeup.sirp.applicants.interfaces import ( 33 IApplicant, IApplicantEdit, 34 IApplicant, IApplicantEdit, IApplicantBaseData, 34 35 ) 36 from waeup.sirp.students.vocabularies import RegNumNotInSource 35 37 36 38 class Applicant(grok.Container): … … 78 80 79 81 def createStudent(self): 80 """Create a student object from applicatntdata82 """Create a student object based on the applicant base data 81 83 and copy applicant object. 82 84 """ 83 85 student = createObject(u'waeup.Student') 86 # Check first if registration number exists 87 try: 88 student.reg_number = self.reg_number 89 except RegNumNotInSource: 90 return False, 'Registration Number exists.' 91 catalog = getUtility(ICatalog, name='certificates_catalog') 92 #import pdb; pdb.set_trace() 93 code = self.course_admitted['code'] 94 if code: 95 cert = [i for i in catalog.searchResults(code=(code,code))][0] 96 else: 97 return False, 'No course admitted provided.' 84 98 site = grok.getSite() 85 86 99 site['students'].addStudent(student) 100 # TODO: Split fullname in students package and copy first, 101 # middle and lastaname 102 87 103 student.fullname = self.fullname 88 return student.student_id 104 student.sex = self.sex 105 student.date_of_birth = self.date_of_birth 106 student.email = self.email 107 student.phone = self.phone 108 student['studycourse'].certificate = cert 109 form_fields = grok.AutoFields(IApplicantBaseData) 110 field_names = [i.__name__ for i in form_fields] 111 application = createObject(u'waeup.StudentApplication') 112 for name in field_names: 113 value = getattr(self,name,None) 114 if value: 115 setattr(application,name,value) 116 site['students'][student.student_id]['application'] = application 117 return True, 'Student with Id %s created' % student.student_id 89 118 90 119 # Set all attributes of Applicant required in IApplicant as field -
main/waeup.sirp/trunk/src/waeup/sirp/applicants/browser.py
r7332 r7341 438 438 grok.template('applicantdisplaypage') 439 439 form_fields = grok.AutoFields(IApplicant).omit( 440 'locked', 'course_admitted', 'password') 440 'locked', 441 'password') 441 442 form_fields['date_of_birth'].custom_widget = FriendlyDateDisplayWidget('le') 442 443 label = 'Applicant' … … 468 469 container_title, self.context.application_number) 469 470 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 '' 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'] 481 480 482 481 class ApplicantBaseDisplayFormPage(ApplicantDisplayFormPage): … … 485 484 form_fields = grok.AutoFields(IApplicant).select( 486 485 'applicant_id', 'firstname', 'lastname','email', 'course1') 486 487 class CreateStudentPage(grok.View): 488 """Create a student object from applicatnt data 489 and copy applicant object. 490 """ 491 grok.context(IApplicant) 492 grok.name('createstudent') 493 grok.require('waeup.manageStudent') 494 495 def update(self): 496 msg = self.context.createStudent()[1] 497 self.flash(msg) 498 self.redirect(self.url(self.context)) 499 return 500 501 def render(self): 502 return 487 503 488 504 class AcceptanceFeePaymentAddPage(grok.View): … … 656 672 grok.require('waeup.viewApplication') 657 673 form_fields = grok.AutoFields(IApplicant).omit( 658 'locked', 'course_admitted') 674 'locked', 675 ) 659 676 form_fields['date_of_birth'].custom_widget = FriendlyDateDisplayWidget('le') 660 677 prefix = 'form' … … 666 683 container_title, self.context.application_number) 667 684 668 def get CourseAdmitted(self):669 """Return title and code in html format to the certificate670 admitted.671 """672 course_admitted = self.context.course_admitted 673 if ICertificate.providedBy(course_admitted):674 title = course_admitted.title675 code = course_admitted.code676 return '%s - %s' %(code,title)677 return '' 685 def getDepartmentAdmitted(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 678 695 679 696 def setUpWidgets(self, ignore_request=False): … … 738 755 f_text = Paragraph(f_text, style["Normal"]) 739 756 data.append([f_label,f_text]) 740 f_label = '<font size=12>Admitted Course of Study:</font>' 741 f_text = '<font size=12>%s</font>' % self.getCourseAdmitted() 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() 742 765 f_label = Paragraph(f_label, style["Normal"]) 743 766 f_text = Paragraph(f_text, style["Normal"]) 744 767 data.append([f_label,f_text]) 768 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]) 774 745 775 # Create table 746 776 table = Table(data,style=SLIP_STYLE) -
main/waeup.sirp/trunk/src/waeup/sirp/applicants/browser_templates/applicantdisplaypage.pt
r7254 r7341 27 27 <tr> 28 28 <td class="fieldname"> 29 Admitted Course of Study:29 Department: 30 30 </td> 31 31 <td> 32 <span tal:replace="structure view/getCourseAdmitted" /> 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" /> 33 41 </td> 34 42 </tr> -
main/waeup.sirp/trunk/src/waeup/sirp/applicants/interfaces.py
r7338 r7341 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 ( 35 lgas_vocab, CertificateSource, GenderSource, 36 ) 34 from waeup.sirp.students.vocabularies import lgas_vocab, GenderSource 37 35 from waeup.sirp.applicants.vocabularies import ( 38 36 application_types_vocab, application_pins_vocab, 39 AppCatCertificate Source,37 AppCatCertificateTitleSource, CertificateTitleSource 40 38 ) 41 39 from waeup.sirp.payments.interfaces import IOnlinePayment … … 345 343 course1 = schema.Choice( 346 344 title = u'1st Choice Course of Study', 347 source = Certificate Source(),345 source = CertificateTitleSource(), 348 346 required = True, 349 347 ) 350 348 course2 = schema.Choice( 351 349 title = u'2nd Choice Course of Study', 352 source = Certificate Source(),350 source = CertificateTitleSource(), 353 351 required = False, 354 352 ) … … 365 363 required = False, 366 364 ) 365 notice = schema.Text( 366 title = u'Notice', 367 required = False, 368 ) 367 369 course_admitted = schema.Choice( 368 370 title = u'Admitted Course of Study', 369 source = CertificateSource(), 370 default = None, 371 required = False, 372 ) 373 notice = schema.Text( 374 title = u'Notice', 371 source = CertificateTitleSource(), 372 default = None, 375 373 required = False, 376 374 ) … … 425 423 course1 = schema.Choice( 426 424 title = u'1st Choice Course of Study', 427 source = AppCatCertificate Source(),425 source = AppCatCertificateTitleSource(), 428 426 required = True, 429 427 ) 430 428 course2 = schema.Choice( 431 429 title = u'2nd Choice Course of Study', 432 source = AppCatCertificate Source(),430 source = AppCatCertificateTitleSource(), 433 431 required = False, 434 432 ) … … 445 443 course_admitted = schema.Choice( 446 444 title = u'Admitted Course of Study', 447 source = Certificate Source(),445 source = CertificateTitleSource(), 448 446 default = None, 449 447 required = False, -
main/waeup.sirp/trunk/src/waeup/sirp/applicants/vocabularies.py
r7321 r7341 21 21 from zope.catalog.interfaces import ICatalog 22 22 from waeup.sirp.interfaces import SimpleSIRPVocabulary 23 from waeup.sirp.students.vocabularies import CertificateSource23 from zc.sourcefactory.contextual import BasicContextualSourceFactory 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 provided 48 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']) 46 60 47 class AppCatCertificateSource(CertificateSource): 48 """An application certificate source delivers all courses which belong to 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 49 69 a certain application_category. 50 70 """ … … 52 72 appcat = context.__parent__.application_category 53 73 catalog = getUtility(ICatalog, name='certificates_catalog') 54 return sorted(list( 55 catalog.searchResults( 56 code=('', 'z*'), 57 application_category=(appcat,appcat))), 58 key=lambda value: value.code) 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
Note: See TracChangeset for help on using the changeset viewer.