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