source: WAeUP_SRP/trunk/skins/waeup_student/start_clearance.py @ 1591

Last change on this file since 1591 was 1571, checked in by Henrik Bettermann, 18 years ago

new logging format Part 4 (rest)

  • Property svn:keywords set to Id
File size: 3.4 KB
Line 
1##parameters=REQUEST
2# $Id: start_clearance.py 1571 2007-03-17 15:25:56Z henrik $
3"""
4request Clearance
5"""
6import DateTime
7current = DateTime.DateTime()
8pr = context.portal_registration
9import logging
10logger = logging.getLogger('Skins.start_clearance')
11
12#type_name = 'Student'
13#ti = context.portal_types[type_name]
14#request.set('type_name',type_name)
15wf = context.portal_workflow
16request=REQUEST
17redirect = request.RESPONSE.redirect
18validate = REQUEST.has_key("cpsdocument_create_button")
19lt = context.portal_layouts
20#pr = context.portal_registration
21
22info = context.getClearanceInfo()
23if 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())
27app_doc = info['app_doc']
28review_state = info['review_state']
29session = REQUEST.SESSION
30res,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                      )
39if 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                                 )
47error = False
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
54if review_state == "clearance_pin_entered":
55    psm = "You have already entered a clearance pin!"
56    error = True
57    logger.info('%s tried to start clearance though already started' % (info['id']))
58elif psm == 'invalid':
59    psm = "Please correct your input!"
60    error = True
61    logger.info('%s entered wrong clearance pin' % (info['id']))
62elif app_doc.passport is None:
63    #psm = "You must upload your passport picture before you can start the registration process!"
64    #error = True
65    logger.info('%s started clearance without passport picture' % (info['id']))
66if error:
67    return context.clearance_pin_form(rendered = res,
68                                 psm = psm,
69                                 firstlayout = True,
70                                 lastlayout = True,
71                                 ds = ds,
72                                 info = info,
73                                 )
74session.set("clicked","clicked")
75pin = str(ds.get('clr_ac_pin'))
76logger.info('%s started clearance with pin %s' % (info['id'],pin))
77wf.doActionFor(info['student'],'enter_clearance_pin')
78wf.doActionFor(info['clear'],'open')
79dc = {}
80app_doc = info['app_doc']
81dc['lga_ident'] = app_doc.get('jamb_lga')
82dc['lga'] = app_doc.get('jamb_state','no state') + ' / ' + app_doc.get('jamb_lga','no lga')
83dc['clr_ac_pin'] = pin
84dc['clr_ac_date'] = current
85dc['entry_date'] = current
86dc['entry_session'] = "2006/2007"
87wf.doActionFor(info['app'],'close')
88info['clear_doc'].edit(mapping = dc)
89
90if info['penalty']:
91    logger.info('%s started late clearance' % (info['id']))
92
93return redirect("%s/clearance_edit_form" % info['clear'].absolute_url())
94
Note: See TracBrowser for help on using the repository browser.