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

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

logging messages modified
Study Course always listed
date labels chsnged

  • Property svn:keywords set to Id
File size: 3.0 KB
Line 
1##parameters=REQUEST
2# $Id: start_clearance.py 1032 2006-12-12 10:00:51Z henrik $
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'
13ti = context.portal_types[type_name]
14REQUEST.set('type_name',type_name)
15redirect = REQUEST.RESPONSE.redirect
16wf = context.portal_workflow
17validate = REQUEST.has_key("cpsdocument_create_button")
18
19lt = context.portal_layouts
20pr = context.portal_registration
21
22info = context.getStudentInfo()
23app_doc = info['app_doc']
24review_state = info['review_state']
25session = REQUEST.SESSION
26res,psm,ds = lt.renderLayout(layout_id='student_clearance',
27                      schema_id= 'student_clearance',
28                      context=context,
29                      mapping=validate and REQUEST,
30                      ob={},
31                      layout_mode='create',
32                      formaction = "start_clearance",
33                      button = "Start",
34                      )
35if psm == '':
36    return context.clearance_pin_form(rendered = res,
37                                 psm = None,
38                                 firstlayout = True,
39                                 lastlayout = True,
40                                 ds = ds,
41                                 )
42error = False
43if session.get("clicked",None):
44    psm = 'Please wait a moment until "Clearance started" turns green, then click on the green link!'
45    error = True
46    logger.info('"%s","repeatedly pressed the clearance button"' % (info['id']))
47elif app_doc.passport is None:
48    psm = "You must upload your passport picture before you can start the registration process!"
49    error = True
50    logger.info('"%s", "tried to start clerance without passport picture"' % (info['id']))
51elif review_state == "clearance_pin_entered":
52    psm = "You have already entered a clearance pin!"
53    error = True
54    logger.info('"%s", "tried to start clearance though already started"' % (info['id']))
55elif psm == 'invalid':
56    psm = "Please correct your input!"
57    error = True
58    logger.info('"%s","entered wrong clearance pin"' % (info['id']))
59if error:
60    return context.clearance_pin_form(rendered = res,
61                                 psm = psm,
62                                 firstlayout = True,
63                                 lastlayout = True,
64                                 ds = ds,
65                                 )
66session.set("clicked","clicked")
67pin = str(ds.get('clr_ac_pin'))
68logger.info('"%s", "started clearance with pin", "%s"' % (info['id'],pin))
69wf.doActionFor(info['student'],'enter_clearance_pin')
70wf.doActionFor(info['clear'],'open')
71dc = {}
72app_doc = info['app_doc']
73dc['lga_ident'] = app_doc.get('jamb_lga')
74dc['lga'] = app_doc.get('jamb_state','no state') + ' / ' + app_doc.get('jamb_lga','no lga')
75dc['clr_ac_pin'] = pin
76dc['clr_ac_date'] = current
77dc['entry_date'] = current
78dc['entry_session'] = "2006/2007"
79wf.doActionFor(info['app'],'close')
80info['clear_doc'].edit(mapping = dc)
81return redirect("%s/clearance_edit_form" % info['clear'].absolute_url())
Note: See TracBrowser for help on using the repository browser.