[798] | 1 | ##parameters=REQUEST |
---|
[805] | 2 | # $Id: start_clearance.py 5257 2010-07-08 04:51:54Z henrik $ |
---|
[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 |
---|
[1857] | 30 | res,psm,ds = lt.renderLayout('student_clearance', |
---|
| 31 | 'student_clearance', |
---|
| 32 | context, |
---|
| 33 | mapping=validate and REQUEST, |
---|
| 34 | layout_mode='create', |
---|
| 35 | ob={}, |
---|
| 36 | commit = False, |
---|
| 37 | formaction = "start_clearance", |
---|
| 38 | button = "Start", |
---|
[798] | 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, |
---|
[1141] | 46 | info = info, |
---|
[798] | 47 | ) |
---|
[1016] | 48 | error = False |
---|
[1364] | 49 | |
---|
| 50 | ##if session.get("clicked",None): |
---|
| 51 | ## psm = 'Please wait a moment until "Clearance started" turns green, then click on the green link!' |
---|
| 52 | ## error = True |
---|
| 53 | ## logger.info('"%s","repeatedly pressed the clearance button"' % (info['id'])) |
---|
| 54 | |
---|
| 55 | if review_state == "clearance_pin_entered": |
---|
[1032] | 56 | psm = "You have already entered a clearance pin!" |
---|
[1016] | 57 | error = True |
---|
[1571] | 58 | logger.info('%s tried to start clearance though already started' % (info['id'])) |
---|
[1016] | 59 | elif psm == 'invalid': |
---|
[1021] | 60 | psm = "Please correct your input!" |
---|
[1016] | 61 | error = True |
---|
[1571] | 62 | logger.info('%s entered wrong clearance pin' % (info['id'])) |
---|
[2690] | 63 | # elif False #app_doc.passport is None: |
---|
| 64 | # #psm = "You must upload your passport picture before you can start the registration process!" |
---|
| 65 | # #error = True |
---|
| 66 | # logger.info('%s started clearance without passport picture' % (info['id'])) |
---|
[1016] | 67 | if error: |
---|
[798] | 68 | return context.clearance_pin_form(rendered = res, |
---|
[1016] | 69 | psm = psm, |
---|
[798] | 70 | firstlayout = True, |
---|
| 71 | lastlayout = True, |
---|
| 72 | ds = ds, |
---|
[1141] | 73 | info = info, |
---|
[798] | 74 | ) |
---|
[1822] | 75 | #session.set("clicked","clicked") |
---|
[1016] | 76 | pin = str(ds.get('clr_ac_pin')) |
---|
[1571] | 77 | logger.info('%s started clearance with pin %s' % (info['id'],pin)) |
---|
[1016] | 78 | wf.doActionFor(info['student'],'enter_clearance_pin') |
---|
[5257] | 79 | #wf.doActionFor(info['clear'],'open') |
---|
| 80 | context.waeup_tool.changeWorkflowState(info['clear'], 'opened') |
---|
[1016] | 81 | dc = {} |
---|
| 82 | app_doc = info['app_doc'] |
---|
[2725] | 83 | #dc['lga'] = app_doc.get('jamb_state','no state') + ' / ' + app_doc.get('jamb_lga','no lga') |
---|
[1027] | 84 | dc['clr_ac_pin'] = pin |
---|
[1016] | 85 | dc['clr_ac_date'] = current |
---|
| 86 | dc['entry_date'] = current |
---|
[3789] | 87 | |
---|
| 88 | a_review_state = wf.getInfoFor(info['app'],'review_state',None) |
---|
| 89 | if a_review_state != 'closed': |
---|
| 90 | wf.doActionFor(info['app'],'close') |
---|
| 91 | |
---|
[1016] | 92 | info['clear_doc'].edit(mapping = dc) |
---|
[1148] | 93 | |
---|
| 94 | if info['penalty']: |
---|
[1571] | 95 | logger.info('%s started late clearance' % (info['id'])) |
---|
[1148] | 96 | |
---|
[798] | 97 | return redirect("%s/clearance_edit_form" % info['clear'].absolute_url()) |
---|
[1364] | 98 | |
---|