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