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

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

modified scratch_card_pin widget to include prefix and batch_no
modified schemas and layouts accordingly.

  • Property svn:keywords set to Id
File size: 3.0 KB
Line 
1##parameters=REQUEST
2# $Id: apply_admission.py 488 2006-09-07 12:34:56Z joachim $
3"""
4process the Application Form
5return html renderer + psm
6"""
7import DateTime
8current = DateTime.DateTime()
9
10
11type_name = 'StudentApplication'
12ti = context.portal_types[type_name]
13REQUEST.set('type_name',type_name)
14
15validate = REQUEST.has_key("cpsdocument_create_button")
16
17lt = context.portal_layouts
18pr = context.portal_registration
19
20res,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                      )
29if 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                                 )
37elif psm == '':
38    return context.application_pin_form(rendered = res,
39                                 psm = None,
40                                 firstlayout = True,
41                                 lastlayout = True,
42                                 ds = ds,
43                                 )
44elif 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                                 )
54application = student.application
55if 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
61apdoc = application.getContent()
62names = apdoc.jamb_lastname.split()
63dp = {}
64if len(names) == 3:
65    dp['firstname'] = names[0].capitalize()
66    dp['middlename'] = names[1].capitalize()
67    dp['lastname'] = names[2].capitalize()
68elif len(names) == 2:
69    dp['firstname'] = names[0].capitalize()
70    dp['lastname'] = names[1].capitalize()
71else:
72    dp['lastname'] = apdoc.jamb_lastname
73dp['sex'] = apdoc.jamb_sex == 'F'
74dp['lga'] = "%s/%s" % (apdoc.jamb_state,apdoc.jamb_lga )
75student.personal.getContent().edit(mapping = dp)
76da = {}
77da['app_ac_pin'] = ds.get('app_ac_pin')
78da['app_ac_date'] = current
79apdoc.edit(mapping = da)
80# now display the passport form with jamb-data readonly
81return context.REQUEST.RESPONSE.redirect("%s/application_form" % (student.application.absolute_url()))
82return student.application_form()
83
84
Note: See TracBrowser for help on using the repository browser.