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

Last change on this file since 1065 was 1051, checked in by joachim, 18 years ago

use srp_invalid_access

  • Property svn:keywords set to Id
File size: 3.3 KB
Line 
1##parameters=REQUEST
2# $Id: start_clearance.py 1051 2006-12-13 18:35:54Z joachim $
3"""
4request Clearance
5"""
6import DateTime
7current = DateTime.DateTime()
8pr = context.portal_registration
9import logging
10logger = logging.getLogger('Student.Clearance.Start')
11
12type_name = 'Student'
13request=REQUEST
14ti = context.portal_types[type_name]
15request.set('type_name',type_name)
16redirect = request.RESPONSE.redirect
17wf = context.portal_workflow
18validate = REQUEST.has_key("cpsdocument_create_button")
19
20lt = context.portal_layouts
21pr = context.portal_registration
22
23info = context.getStudentInfo()
24if info is None:
25    member_id = str(context.portal_membership.getAuthenticatedMember())
26    logger.info('"%s","access to", "%s"' % (member_id,request.get('PATH_INFO').split('/')[-2]))
27    return redirect("%s/srp_invalid_access" % context.portal_url())
28app_doc = info['app_doc']
29review_state = info['review_state']
30session = REQUEST.SESSION
31res,psm,ds = lt.renderLayout(layout_id='student_clearance',
32                      schema_id= 'student_clearance',
33                      context=context,
34                      mapping=validate and REQUEST,
35                      ob={},
36                      layout_mode='create',
37                      formaction = "start_clearance",
38                      button = "Start",
39                      )
40if psm == '':
41    return context.clearance_pin_form(rendered = res,
42                                 psm = None,
43                                 firstlayout = True,
44                                 lastlayout = True,
45                                 ds = ds,
46                                 )
47error = False
48if 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']))
52elif 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']))
56elif 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']))
60elif psm == 'invalid':
61    psm = "Please correct your input!"
62    error = True
63    logger.info('"%s","entered wrong clearance pin"' % (info['id']))
64if error:
65    return context.clearance_pin_form(rendered = res,
66                                 psm = psm,
67                                 firstlayout = True,
68                                 lastlayout = True,
69                                 ds = ds,
70                                 )
71session.set("clicked","clicked")
72pin = str(ds.get('clr_ac_pin'))
73logger.info('"%s", "started clearance with pin", "%s"' % (info['id'],pin))
74wf.doActionFor(info['student'],'enter_clearance_pin')
75wf.doActionFor(info['clear'],'open')
76dc = {}
77app_doc = info['app_doc']
78dc['lga_ident'] = app_doc.get('jamb_lga')
79dc['lga'] = app_doc.get('jamb_state','no state') + ' / ' + app_doc.get('jamb_lga','no lga')
80dc['clr_ac_pin'] = pin
81dc['clr_ac_date'] = current
82dc['entry_date'] = current
83dc['entry_session'] = "2006/2007"
84wf.doActionFor(info['app'],'close')
85info['clear_doc'].edit(mapping = dc)
86return redirect("%s/clearance_edit_form" % info['clear'].absolute_url())
Note: See TracBrowser for help on using the repository browser.