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

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

logger message for late clearance added

  • Property svn:keywords set to Id
File size: 3.5 KB
RevLine 
[798]1##parameters=REQUEST
[805]2# $Id: start_clearance.py 1148 2006-12-29 19:49:51Z henrik $
[798]3"""
4request Clearance
5"""
6import DateTime
7current = DateTime.DateTime()
8pr = context.portal_registration
[1016]9import logging
10logger = logging.getLogger('Student.Clearance.Start')
[798]11
[1141]12#type_name = 'Student'
13#ti = context.portal_types[type_name]
14#request.set('type_name',type_name)
[1144]15wf = context.portal_workflow
[1051]16request=REQUEST
17redirect = request.RESPONSE.redirect
[798]18validate = REQUEST.has_key("cpsdocument_create_button")
19lt = context.portal_layouts
[1141]20#pr = context.portal_registration
[798]21
[1141]22info = context.getClearanceInfo()
[1051]23if info is None:
24    member_id = str(context.portal_membership.getAuthenticatedMember())
[1108]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]27app_doc = info['app_doc']
28review_state = info['review_state']
[1030]29session = REQUEST.SESSION
[798]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                      )
[1016]39if 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]47error = False
[1030]48if 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]52elif 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]56elif 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]60elif 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]64if error:
[798]65    return context.clearance_pin_form(rendered = res,
[1016]66                                 psm = psm,
[798]67                                 firstlayout = True,
68                                 lastlayout = True,
69                                 ds = ds,
[1141]70                                 info = info,
[798]71                                 )
[1030]72session.set("clicked","clicked")
[1016]73pin = str(ds.get('clr_ac_pin'))
[1032]74logger.info('"%s", "started clearance with pin", "%s"' % (info['id'],pin))
[1016]75wf.doActionFor(info['student'],'enter_clearance_pin')
76wf.doActionFor(info['clear'],'open')
77dc = {}
78app_doc = info['app_doc']
79dc['lga_ident'] = app_doc.get('jamb_lga')
[1017]80dc['lga'] = app_doc.get('jamb_state','no state') + ' / ' + app_doc.get('jamb_lga','no lga')
[1027]81dc['clr_ac_pin'] = pin
[1016]82dc['clr_ac_date'] = current
83dc['entry_date'] = current
84dc['entry_session'] = "2006/2007"
85wf.doActionFor(info['app'],'close')
86info['clear_doc'].edit(mapping = dc)
[1148]87
88if info['penalty']:
89    logger.info('"%s","started late clearance"' % (info['id']))
90
[798]91return redirect("%s/clearance_edit_form" % info['clear'].absolute_url())
Note: See TracBrowser for help on using the repository browser.