1 | ##parameters=REQUEST |
---|
2 | # $Id: apply_admission.py 488 2006-09-07 12:34:56Z 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 | res,psm,ds = lt.renderLayout(layout_id= 'student_application_fe', |
---|
21 | schema_id= 'student_application', |
---|
22 | context=context, |
---|
23 | mapping=validate and REQUEST, |
---|
24 | ob={}, |
---|
25 | layout_mode='create', |
---|
26 | formaction = "apply_admission", |
---|
27 | submit = "check", |
---|
28 | ) |
---|
29 | if psm == 'invalid': |
---|
30 | return context.application_pin_form(rendered = res, |
---|
31 | psm = "Please correct your input.", |
---|
32 | #psm = "%s, %s" % (psm,ds), |
---|
33 | firstlayout = True, |
---|
34 | lastlayout = True, |
---|
35 | ds = ds, |
---|
36 | ) |
---|
37 | elif psm == '': |
---|
38 | return context.application_pin_form(rendered = res, |
---|
39 | psm = None, |
---|
40 | firstlayout = True, |
---|
41 | lastlayout = True, |
---|
42 | ds = ds, |
---|
43 | ) |
---|
44 | elif psm == 'valid': |
---|
45 | jamb_id = ds.get('jamb_reg_no') |
---|
46 | student = context.getContent().getStudentByRegNo(jamb_id) |
---|
47 | if student is None: |
---|
48 | psm = "JAMB record %s not accessible." % (jamb_id) |
---|
49 | return context.application_pin_form(rendered = res, |
---|
50 | psm = psm, |
---|
51 | #psm = "%s, %s" % (psm,ds), |
---|
52 | ds = ds, |
---|
53 | ) |
---|
54 | application = student.application |
---|
55 | if context.portal_workflow.getInfoFor(student,'review_state',None) == "created": |
---|
56 | #student.invokeFactory('StudentClearance','clearance') |
---|
57 | student.invokeFactory('StudentPersonal','personal') |
---|
58 | student.content_status_modify(workflow_action="enter_application_pin") |
---|
59 | |
---|
60 | |
---|
61 | apdoc = application.getContent() |
---|
62 | names = apdoc.jamb_lastname.split() |
---|
63 | dp = {} |
---|
64 | if len(names) == 3: |
---|
65 | dp['firstname'] = names[0].capitalize() |
---|
66 | dp['middlename'] = names[1].capitalize() |
---|
67 | dp['lastname'] = names[2].capitalize() |
---|
68 | elif len(names) == 2: |
---|
69 | dp['firstname'] = names[0].capitalize() |
---|
70 | dp['lastname'] = names[1].capitalize() |
---|
71 | else: |
---|
72 | dp['lastname'] = apdoc.jamb_lastname |
---|
73 | dp['sex'] = apdoc.jamb_sex == 'F' |
---|
74 | dp['lga'] = "%s/%s" % (apdoc.jamb_state,apdoc.jamb_lga ) |
---|
75 | student.personal.getContent().edit(mapping = dp) |
---|
76 | da = {} |
---|
77 | da['app_ac_pin'] = ds.get('app_ac_pin') |
---|
78 | da['app_ac_date'] = current |
---|
79 | apdoc.edit(mapping = da) |
---|
80 | # now display the passport form with jamb-data readonly |
---|
81 | return context.REQUEST.RESPONSE.redirect("%s/application_form" % (student.application.absolute_url())) |
---|
82 | return student.application_form() |
---|
83 | |
---|
84 | |
---|