source: WAeUP_SRP/trunk/skins/waeup_student/apply_admission.py @ 478

Last change on this file since 478 was 478, checked in by joachim, 18 years ago

apply_admission basics

File size: 2.9 KB
Line 
1##parameters=REQUEST
2# $Id: apply_admission.py 173 2005-11-15 16:28:29Z joachim $
3"""
4process the Application Form
5return html renderer + psm
6"""
7import DateTime
8current = DateTime.DateTime()
9
10type_name = 'StudentApplication'
11
12ti = context.portal_types[type_name]
13
14REQUEST.set('type_name',type_name)
15
16validate = REQUEST.has_key("cpsdocument_create_button")
17
18
19lt = context.portal_layouts
20pr = context.portal_registration
21
22res,psm,ds = lt.renderLayout(layout_id= 'student_check_pin',
23                      schema_id= 'student_check_pin',
24                      context=context,
25                      mapping=validate and REQUEST,
26                      ob={},
27                      layout_mode='create',
28                      formaction = "apply_admission",
29                      submit = "check",
30                      )
31if psm == 'invalid':
32    return context.application_pin_form(rendered = res,
33                                 #psm = "Please correct your input",
34                                 psm = "psm : #%s#" % (psm,),
35                                 firstlayout = True,
36                                 lastlayout = True,
37                                 ds = ds,
38                                 )
39elif psm == '':
40    return context.application_pin_form(rendered = res,
41                                 psm = None,
42                                 firstlayout = True,
43                                 lastlayout = True,
44                                 ds = ds,
45                                 )
46elif psm == 'valid':
47    jamb_id = ds.get('jamb_reg_no')
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                                 )
59application = search[0].getObject()
60student = application.aq_parent
61if 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
66apdoc = application.getContent()
67names = apdoc.jamb_lastname.split()
68dp = {}
69if len(names) == 3:
70    dp['firstname'] = names[0].capitalize()
71    dp['middlename'] = names[1].capitalize()
72    dp['lastname'] = names[2].capitalize()
73elif len(names) == 2:
74    dp['firstname'] = names[0].capitalize()
75    dp['lastname'] = names[1].capitalize()
76else:
77    dp['lastname'] = apdoc.jamb_lastname
78dp['sex'] = apdoc.jamb_sex == 'M'
79dp['lga'] = "%s/%s" % (apdoc.jamb_state,apdoc.jamb_lga )
80student.personal.getContent().edit(mapping = dp)
81da = {}
82da['app_ac_pin'] = ds['pin']
83apdoc.edit(mapping = da)
84# now display the passport form with jamb-data readonly
85return student.application_form()
86
87
Note: See TracBrowser for help on using the repository browser.