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