1 | ##parameters=REQUEST |
---|
2 | # $Id: clearence.py 166 2005-11-12 14:45:08Z joachim $ |
---|
3 | """ |
---|
4 | process the Admission Form |
---|
5 | return html renderer + psm |
---|
6 | """ |
---|
7 | import DateTime |
---|
8 | current = DateTime.DateTime() |
---|
9 | |
---|
10 | |
---|
11 | type_name = 'Jamb' |
---|
12 | ti = context.portal_types[type_name] |
---|
13 | |
---|
14 | REQUEST.set('type_name',type_name) |
---|
15 | |
---|
16 | validate = REQUEST.has_key("cpsdocument_edit_button") |
---|
17 | |
---|
18 | |
---|
19 | lt = context.portal_layouts |
---|
20 | pr = context.portal_registration |
---|
21 | |
---|
22 | res,psm,ds = lt.renderLayout(layout_id= 'clearence', |
---|
23 | schema_id= 'student_clearence', |
---|
24 | context=context, |
---|
25 | mapping=validate and REQUEST, |
---|
26 | ob={}, |
---|
27 | layout_mode='create', |
---|
28 | action = "clearence", |
---|
29 | submit = "submit", |
---|
30 | ) |
---|
31 | |
---|
32 | if psm == 'invalid': |
---|
33 | return context.clearence_form(rendered = res, |
---|
34 | psm = "Please correct your input", |
---|
35 | ds = ds, |
---|
36 | ) |
---|
37 | elif psm == '': |
---|
38 | return context.clearence_form(rendered = res, |
---|
39 | psm = None, |
---|
40 | ds = ds, |
---|
41 | ) |
---|
42 | elif psm == 'valid': |
---|
43 | s_id = "s%s" % ds.get('jamb_id') |
---|
44 | catalog = context.portal_catalog |
---|
45 | search = catalog(SearchableText = "%s*" % s_id) |
---|
46 | if len(search) < 1: |
---|
47 | psm = "Your not admitted" |
---|
48 | return context.clearence_form(rendered = res, |
---|
49 | psm = psm, |
---|
50 | ds = ds, |
---|
51 | ) |
---|
52 | sf = getattr(context,s_id,None) |
---|
53 | if sf and getattr(sf,'PERSONAL',None): |
---|
54 | psm = "Your already admitted, please login" |
---|
55 | return context.clearence_form(rendered = res, |
---|
56 | psm = psm, |
---|
57 | ds = ds, |
---|
58 | ) |
---|
59 | rset = REQUEST.set |
---|
60 | student = getattr(context,s_id) |
---|
61 | ds.set('sc_date',current) |
---|
62 | student.getContent().setScratchCardData('clearence',ds) |
---|
63 | sc_pin = ds.get('sc_pin') |
---|
64 | return REQUEST.RESPONSE.redirect("%s/logged_in?__ac_name=%s&__ac_password=UnSeT&sc_pin=%s" |
---|
65 | % (context.absolute_url(),s_id,sc_pin)) |
---|