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