[798] | 1 | ##parameters=REQUEST |
---|
[805] | 2 | # $Id: start_clearance.py 1032 2006-12-12 10:00:51Z henrik $ |
---|
[798] | 3 | """ |
---|
| 4 | request Clearance |
---|
| 5 | """ |
---|
| 6 | import DateTime |
---|
| 7 | current = DateTime.DateTime() |
---|
| 8 | pr = context.portal_registration |
---|
[1016] | 9 | import logging |
---|
| 10 | logger = logging.getLogger('Student.Clearance.Start') |
---|
[798] | 11 | |
---|
| 12 | type_name = 'Student' |
---|
| 13 | ti = context.portal_types[type_name] |
---|
| 14 | REQUEST.set('type_name',type_name) |
---|
| 15 | redirect = REQUEST.RESPONSE.redirect |
---|
| 16 | wf = context.portal_workflow |
---|
| 17 | validate = REQUEST.has_key("cpsdocument_create_button") |
---|
| 18 | |
---|
| 19 | lt = context.portal_layouts |
---|
| 20 | pr = context.portal_registration |
---|
| 21 | |
---|
[1016] | 22 | info = context.getStudentInfo() |
---|
| 23 | app_doc = info['app_doc'] |
---|
| 24 | review_state = info['review_state'] |
---|
[1030] | 25 | session = REQUEST.SESSION |
---|
[798] | 26 | res,psm,ds = lt.renderLayout(layout_id='student_clearance', |
---|
| 27 | schema_id= 'student_clearance', |
---|
| 28 | context=context, |
---|
| 29 | mapping=validate and REQUEST, |
---|
| 30 | ob={}, |
---|
| 31 | layout_mode='create', |
---|
| 32 | formaction = "start_clearance", |
---|
| 33 | button = "Start", |
---|
| 34 | ) |
---|
[1016] | 35 | if psm == '': |
---|
[798] | 36 | return context.clearance_pin_form(rendered = res, |
---|
[1016] | 37 | psm = None, |
---|
[798] | 38 | firstlayout = True, |
---|
| 39 | lastlayout = True, |
---|
| 40 | ds = ds, |
---|
| 41 | ) |
---|
[1016] | 42 | error = False |
---|
[1030] | 43 | if session.get("clicked",None): |
---|
[1032] | 44 | psm = 'Please wait a moment until "Clearance started" turns green, then click on the green link!' |
---|
[1030] | 45 | error = True |
---|
[1032] | 46 | logger.info('"%s","repeatedly pressed the clearance button"' % (info['id'])) |
---|
[1030] | 47 | elif app_doc.passport is None: |
---|
[1016] | 48 | psm = "You must upload your passport picture before you can start the registration process!" |
---|
| 49 | error = True |
---|
[1032] | 50 | logger.info('"%s", "tried to start clerance without passport picture"' % (info['id'])) |
---|
[1016] | 51 | elif review_state == "clearance_pin_entered": |
---|
[1032] | 52 | psm = "You have already entered a clearance pin!" |
---|
[1016] | 53 | error = True |
---|
[1032] | 54 | logger.info('"%s", "tried to start clearance though already started"' % (info['id'])) |
---|
[1016] | 55 | elif psm == 'invalid': |
---|
[1021] | 56 | psm = "Please correct your input!" |
---|
[1016] | 57 | error = True |
---|
[1032] | 58 | logger.info('"%s","entered wrong clearance pin"' % (info['id'])) |
---|
[1016] | 59 | if error: |
---|
[798] | 60 | return context.clearance_pin_form(rendered = res, |
---|
[1016] | 61 | psm = psm, |
---|
[798] | 62 | firstlayout = True, |
---|
| 63 | lastlayout = True, |
---|
| 64 | ds = ds, |
---|
| 65 | ) |
---|
[1030] | 66 | session.set("clicked","clicked") |
---|
[1016] | 67 | pin = str(ds.get('clr_ac_pin')) |
---|
[1032] | 68 | logger.info('"%s", "started clearance with pin", "%s"' % (info['id'],pin)) |
---|
[1016] | 69 | wf.doActionFor(info['student'],'enter_clearance_pin') |
---|
| 70 | wf.doActionFor(info['clear'],'open') |
---|
| 71 | dc = {} |
---|
| 72 | app_doc = info['app_doc'] |
---|
| 73 | dc['lga_ident'] = app_doc.get('jamb_lga') |
---|
[1017] | 74 | dc['lga'] = app_doc.get('jamb_state','no state') + ' / ' + app_doc.get('jamb_lga','no lga') |
---|
[1027] | 75 | dc['clr_ac_pin'] = pin |
---|
[1016] | 76 | dc['clr_ac_date'] = current |
---|
| 77 | dc['entry_date'] = current |
---|
| 78 | dc['entry_session'] = "2006/2007" |
---|
| 79 | wf.doActionFor(info['app'],'close') |
---|
| 80 | info['clear_doc'].edit(mapping = dc) |
---|
[798] | 81 | return redirect("%s/clearance_edit_form" % info['clear'].absolute_url()) |
---|