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 | |
---|
11 | type_name = 'StudentApplication' |
---|
12 | ti = context.portal_types[type_name] |
---|
13 | REQUEST.set('type_name',type_name) |
---|
14 | |
---|
15 | validate = REQUEST.has_key("cpsdocument_create_button") |
---|
16 | |
---|
17 | lt = context.portal_layouts |
---|
18 | pr = context.portal_registration |
---|
19 | |
---|
20 | prefix = 'APP' |
---|
21 | res,psm,ds = lt.renderLayout(layout_id= 'student_application_fe', |
---|
22 | schema_id= 'student_application', |
---|
23 | context=context, |
---|
24 | mapping=validate and REQUEST, |
---|
25 | ob={'app_ac_prefix': prefix}, |
---|
26 | layout_mode='create', |
---|
27 | formaction = "apply_admission", |
---|
28 | submit = "check", |
---|
29 | ) |
---|
30 | if psm == 'invalid': |
---|
31 | return context.application_pin_form(rendered = res, |
---|
32 | psm = "Please correct your input", |
---|
33 | #psm = "psm : #%s#" % (psm,), |
---|
34 | firstlayout = True, |
---|
35 | lastlayout = True, |
---|
36 | ds = ds, |
---|
37 | ) |
---|
38 | elif psm == '': |
---|
39 | return context.application_pin_form(rendered = res, |
---|
40 | psm = None, |
---|
41 | firstlayout = True, |
---|
42 | lastlayout = True, |
---|
43 | ds = ds, |
---|
44 | ) |
---|
45 | elif psm == 'valid': |
---|
46 | jamb_id = ds.get('jamb_reg_no') |
---|
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 |
---|
60 | if context.portal_workflow.getInfoFor(student,'review_state',None) == "created": |
---|
61 | #student.invokeFactory('StudentClearance','clearance') |
---|
62 | student.invokeFactory('StudentPersonal','personal') |
---|
63 | student.content_status_modify(workflow_action="enter_application_pin") |
---|
64 | |
---|
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_prefix'] = prefix |
---|
83 | da['app_ac_batch_no'] = ds.get('app_ac_batch_no') |
---|
84 | da['app_ac_pin'] = ds.get('app_ac_pin') |
---|
85 | da['app_ac_date'] = current |
---|
86 | apdoc.edit(mapping = da) |
---|
87 | # now display the passport form with jamb-data readonly |
---|
88 | return context.REQUEST.RESPONSE.redirect("%s/application_form" % (student.application.absolute_url())) |
---|
89 | return student.application_form() |
---|
90 | |
---|
91 | |
---|