[477] | 1 | ##parameters=REQUEST |
---|
| 2 | # $Id: apply_admission.py 173 2005-11-15 16:28:29Z joachim $ |
---|
| 3 | """ |
---|
| 4 | process the Application Form |
---|
| 5 | return html renderer + psm |
---|
| 6 | """ |
---|
| 7 | type_name = 'StudentApplication' |
---|
| 8 | ti = context.portal_types[type_name] |
---|
| 9 | REQUEST.set('type_name',type_name) |
---|
| 10 | |
---|
[478] | 11 | validate = REQUEST.has_key("cpsdocument_create_button") |
---|
[477] | 12 | |
---|
| 13 | lt = context.portal_layouts |
---|
| 14 | pr = context.portal_registration |
---|
| 15 | |
---|
[479] | 16 | prefix = 'APP' |
---|
| 17 | res,psm,ds = lt.renderLayout(layout_id= 'student_application_fe', |
---|
| 18 | schema_id= 'student_application', |
---|
[477] | 19 | context=context, |
---|
| 20 | mapping=validate and REQUEST, |
---|
[479] | 21 | ob={'app_ac_prefix': prefix}, |
---|
[477] | 22 | layout_mode='create', |
---|
| 23 | formaction = "apply_admission", |
---|
| 24 | submit = "check", |
---|
| 25 | ) |
---|
| 26 | if psm == 'invalid': |
---|
| 27 | return context.application_pin_form(rendered = res, |
---|
[478] | 28 | #psm = "Please correct your input", |
---|
| 29 | psm = "psm : #%s#" % (psm,), |
---|
| 30 | firstlayout = True, |
---|
| 31 | lastlayout = True, |
---|
[477] | 32 | ds = ds, |
---|
| 33 | ) |
---|
| 34 | elif psm == '': |
---|
| 35 | return context.application_pin_form(rendered = res, |
---|
| 36 | psm = None, |
---|
[478] | 37 | firstlayout = True, |
---|
| 38 | lastlayout = True, |
---|
[477] | 39 | ds = ds, |
---|
| 40 | ) |
---|
| 41 | elif psm == 'valid': |
---|
[478] | 42 | jamb_id = ds.get('jamb_reg_no') |
---|
[477] | 43 | catalog = context.portal_catalog |
---|
| 44 | search = catalog({'meta_type': 'StudentApplication', |
---|
| 45 | 'jamb_reg_no': jamb_id |
---|
| 46 | }) |
---|
| 47 | |
---|
| 48 | if len(search) < 1: |
---|
| 49 | psm = "No JAMB record %s" % (jamb_id) |
---|
| 50 | return context.application_pin_form(rendered = res, |
---|
| 51 | psm = psm, |
---|
| 52 | ds = ds, |
---|
| 53 | ) |
---|
| 54 | application = search[0].getObject() |
---|
| 55 | student = application.aq_parent |
---|
[478] | 56 | if context.portal_workflow.getInfoFor(student,'review_state',None) == "created": |
---|
[479] | 57 | #student.invokeFactory('StudentClearance','clearance') |
---|
[478] | 58 | student.invokeFactory('StudentPersonal','personal') |
---|
| 59 | student.content_status_modify(workflow_action="enter_application_pin") |
---|
| 60 | |
---|
[479] | 61 | |
---|
[478] | 62 | apdoc = application.getContent() |
---|
| 63 | names = apdoc.jamb_lastname.split() |
---|
| 64 | dp = {} |
---|
| 65 | if len(names) == 3: |
---|
| 66 | dp['firstname'] = names[0].capitalize() |
---|
| 67 | dp['middlename'] = names[1].capitalize() |
---|
| 68 | dp['lastname'] = names[2].capitalize() |
---|
| 69 | elif len(names) == 2: |
---|
| 70 | dp['firstname'] = names[0].capitalize() |
---|
| 71 | dp['lastname'] = names[1].capitalize() |
---|
| 72 | else: |
---|
| 73 | dp['lastname'] = apdoc.jamb_lastname |
---|
| 74 | dp['sex'] = apdoc.jamb_sex == 'M' |
---|
| 75 | dp['lga'] = "%s/%s" % (apdoc.jamb_state,apdoc.jamb_lga ) |
---|
| 76 | student.personal.getContent().edit(mapping = dp) |
---|
| 77 | da = {} |
---|
[479] | 78 | da['app_ac_prefix'] = prefix |
---|
| 79 | da['app_ac_batch_no'] = ds.get('app_ac_batch_no') |
---|
| 80 | da['app_ac_pin'] = ds.get('app_ac_pin') |
---|
[478] | 81 | apdoc.edit(mapping = da) |
---|
[477] | 82 | # now display the passport form with jamb-data readonly |
---|
[479] | 83 | return context.REQUEST.RESPONSE.redirect("%s/application_form" % (student.application.absolute_url())) |
---|
[477] | 84 | return student.application_form() |
---|
| 85 | |
---|
| 86 | |
---|