[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 | import DateTime |
---|
| 8 | current = DateTime.DateTime() |
---|
| 9 | |
---|
| 10 | type_name = 'StudentApplication' |
---|
| 11 | |
---|
| 12 | ti = context.portal_types[type_name] |
---|
| 13 | |
---|
| 14 | REQUEST.set('type_name',type_name) |
---|
| 15 | |
---|
[478] | 16 | validate = REQUEST.has_key("cpsdocument_create_button") |
---|
[477] | 17 | |
---|
| 18 | |
---|
| 19 | lt = context.portal_layouts |
---|
| 20 | pr = context.portal_registration |
---|
| 21 | |
---|
| 22 | res,psm,ds = lt.renderLayout(layout_id= 'student_check_pin', |
---|
[478] | 23 | schema_id= 'student_check_pin', |
---|
[477] | 24 | context=context, |
---|
| 25 | mapping=validate and REQUEST, |
---|
| 26 | ob={}, |
---|
| 27 | layout_mode='create', |
---|
| 28 | formaction = "apply_admission", |
---|
| 29 | submit = "check", |
---|
| 30 | ) |
---|
| 31 | if psm == 'invalid': |
---|
| 32 | return context.application_pin_form(rendered = res, |
---|
[478] | 33 | #psm = "Please correct your input", |
---|
| 34 | psm = "psm : #%s#" % (psm,), |
---|
| 35 | firstlayout = True, |
---|
| 36 | lastlayout = True, |
---|
[477] | 37 | ds = ds, |
---|
| 38 | ) |
---|
| 39 | elif psm == '': |
---|
| 40 | return context.application_pin_form(rendered = res, |
---|
| 41 | psm = None, |
---|
[478] | 42 | firstlayout = True, |
---|
| 43 | lastlayout = True, |
---|
[477] | 44 | ds = ds, |
---|
| 45 | ) |
---|
| 46 | elif psm == 'valid': |
---|
[478] | 47 | jamb_id = ds.get('jamb_reg_no') |
---|
[477] | 48 | catalog = context.portal_catalog |
---|
| 49 | search = catalog({'meta_type': 'StudentApplication', |
---|
| 50 | 'jamb_reg_no': jamb_id |
---|
| 51 | }) |
---|
| 52 | |
---|
| 53 | if len(search) < 1: |
---|
| 54 | psm = "No JAMB record %s" % (jamb_id) |
---|
| 55 | return context.application_pin_form(rendered = res, |
---|
| 56 | psm = psm, |
---|
| 57 | ds = ds, |
---|
| 58 | ) |
---|
| 59 | application = search[0].getObject() |
---|
| 60 | student = application.aq_parent |
---|
[478] | 61 | if context.portal_workflow.getInfoFor(student,'review_state',None) == "created": |
---|
| 62 | student.invokeFactory('StudentClearance','clearance') |
---|
| 63 | student.invokeFactory('StudentPersonal','personal') |
---|
| 64 | student.content_status_modify(workflow_action="enter_application_pin") |
---|
| 65 | |
---|
| 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 = {} |
---|
| 82 | da['app_ac_pin'] = ds['pin'] |
---|
| 83 | apdoc.edit(mapping = da) |
---|
[477] | 84 | # now display the passport form with jamb-data readonly |
---|
| 85 | return student.application_form() |
---|
| 86 | |
---|
| 87 | |
---|