1 | ##parameters=REQUEST |
---|
2 | # $Id: start_clearance.py 843 2006-11-11 17:40:02Z joachim $ |
---|
3 | """ |
---|
4 | request Clearance |
---|
5 | """ |
---|
6 | import DateTime |
---|
7 | current = DateTime.DateTime() |
---|
8 | pr = context.portal_registration |
---|
9 | |
---|
10 | type_name = 'Student' |
---|
11 | ti = context.portal_types[type_name] |
---|
12 | REQUEST.set('type_name',type_name) |
---|
13 | redirect = REQUEST.RESPONSE.redirect |
---|
14 | wf = context.portal_workflow |
---|
15 | validate = REQUEST.has_key("cpsdocument_create_button") |
---|
16 | |
---|
17 | lt = context.portal_layouts |
---|
18 | pr = context.portal_registration |
---|
19 | |
---|
20 | res,psm,ds = lt.renderLayout(layout_id='student_clearance', |
---|
21 | schema_id= 'student_clearance', |
---|
22 | context=context, |
---|
23 | mapping=validate and REQUEST, |
---|
24 | ob={}, |
---|
25 | layout_mode='create', |
---|
26 | formaction = "start_clearance", |
---|
27 | button = "Start", |
---|
28 | ) |
---|
29 | |
---|
30 | info = context.getStudentInfo() |
---|
31 | app_doc = info['app_doc'] |
---|
32 | if app_doc.passport is None: |
---|
33 | return context.clearance_pin_form(rendered = res, |
---|
34 | psm = "You must upload your passport picture before you can start the registration process.", |
---|
35 | #psm = "%s, %s" % (psm,ds), |
---|
36 | firstlayout = True, |
---|
37 | lastlayout = True, |
---|
38 | ds = ds, |
---|
39 | ) |
---|
40 | |
---|
41 | if psm == 'invalid': |
---|
42 | return context.clearance_pin_form(rendered = res, |
---|
43 | psm = "Please correct your input.", |
---|
44 | #psm = "%s, %s" % (psm,ds), |
---|
45 | firstlayout = True, |
---|
46 | lastlayout = True, |
---|
47 | ds = ds, |
---|
48 | ) |
---|
49 | elif psm == '': |
---|
50 | return context.clearance_pin_form(rendered = res, |
---|
51 | psm = None, |
---|
52 | firstlayout = True, |
---|
53 | lastlayout = True, |
---|
54 | ds = ds, |
---|
55 | ) |
---|
56 | elif psm == 'valid': |
---|
57 | info = context.getStudentInfo() |
---|
58 | review_state = info['review_state'] |
---|
59 | wf.doActionFor(info['student'],'enter_clearance_pin') |
---|
60 | wf.doActionFor(info['app'],'close') |
---|
61 | wf.doActionFor(info['clear'],'open') |
---|
62 | pin = str(ds.get('clr_ac_pin')) |
---|
63 | dc = {} |
---|
64 | dc['clr_ac_pin'] = pin |
---|
65 | dc['clr_ac_date'] = current |
---|
66 | dc['entry_date'] = current |
---|
67 | dc['entry_session'] = "2006/2007" |
---|
68 | info['clear_doc'].edit(mapping = dc) |
---|
69 | return redirect("%s/clearance_edit_form" % info['clear'].absolute_url()) |
---|