[164] | 1 | ##parameters=REQUEST |
---|
| 2 | # $Id: clearance.py 177 2005-11-16 08:16:29Z henrik $ |
---|
| 3 | """ |
---|
| 4 | process the Admission Form |
---|
| 5 | return html renderer + psm |
---|
| 6 | """ |
---|
[166] | 7 | import DateTime |
---|
| 8 | current = DateTime.DateTime() |
---|
| 9 | |
---|
| 10 | |
---|
[164] | 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', |
---|
[173] | 28 | action = "clearance", |
---|
[166] | 29 | submit = "submit", |
---|
[164] | 30 | ) |
---|
[166] | 31 | |
---|
[164] | 32 | if psm == 'invalid': |
---|
[173] | 33 | return context.clearance_form(rendered = res, |
---|
[164] | 34 | psm = "Please correct your input", |
---|
| 35 | ds = ds, |
---|
| 36 | ) |
---|
| 37 | elif psm == '': |
---|
[173] | 38 | return context.clearance_form(rendered = res, |
---|
[164] | 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: |
---|
[177] | 47 | psm = "You are not admitted" |
---|
[173] | 48 | return context.clearance_form(rendered = res, |
---|
[164] | 49 | psm = psm, |
---|
| 50 | ds = ds, |
---|
| 51 | ) |
---|
| 52 | sf = getattr(context,s_id,None) |
---|
| 53 | if sf and getattr(sf,'PERSONAL',None): |
---|
[177] | 54 | psm = "Your are already admitted, please login" |
---|
[173] | 55 | return context.clearance_form(rendered = res, |
---|
[164] | 56 | psm = psm, |
---|
| 57 | ds = ds, |
---|
| 58 | ) |
---|
| 59 | rset = REQUEST.set |
---|
| 60 | student = getattr(context,s_id) |
---|
[166] | 61 | ds.set('sc_date',current) |
---|
[173] | 62 | student.getContent().setScratchCardData('clearance',ds) |
---|
[164] | 63 | sc_pin = ds.get('sc_pin') |
---|
[177] | 64 | #return REQUEST.RESPONSE.redirect("%s/logged_in?__ac_name=%s&__ac_password=UnSeT&sc_pin=%s" |
---|
| 65 | return REQUEST.RESPONSE.redirect("%s/logged_in?__ac_name=%s&__ac_password=123456&sc_pin=%s" |
---|
[164] | 66 | % (context.absolute_url(),s_id,sc_pin)) |
---|