1 | ##parameters=REQUEST |
---|
2 | # $Id: apply_admission.py 543 2006-09-24 07:44:32Z henrik $ |
---|
3 | """ |
---|
4 | process the Application Form |
---|
5 | return html renderer + psm |
---|
6 | """ |
---|
7 | import DateTime |
---|
8 | current = DateTime.DateTime() |
---|
9 | pr = context.portal_registration |
---|
10 | |
---|
11 | info = context.getStudentInfo() |
---|
12 | validate = REQUEST.has_key("cpsdocument_create_button") |
---|
13 | |
---|
14 | lt = context.portal_layouts |
---|
15 | pr = context.portal_registration |
---|
16 | |
---|
17 | res,psm,ds = lt.renderLayout(layout_id= 'student_acco_reserve', |
---|
18 | schema_id= 'student_acco_reserve', |
---|
19 | context=context, |
---|
20 | mapping=validate and REQUEST, |
---|
21 | ob={}, |
---|
22 | layout_mode='create', |
---|
23 | formaction = "reserve_acco", |
---|
24 | button = "book Bed", |
---|
25 | ) |
---|
26 | if psm == 'invalid': |
---|
27 | return context.acco_reserve_form(rendered = res, |
---|
28 | #psm = "Please correct your input.", |
---|
29 | psm = "%s, %s" % (psm,ds), |
---|
30 | firstlayout = True, |
---|
31 | lastlayout = True, |
---|
32 | ds = ds, |
---|
33 | ) |
---|
34 | elif psm == '': |
---|
35 | return context.acco_reserve_form(rendered = res, |
---|
36 | psm = None, |
---|
37 | firstlayout = True, |
---|
38 | lastlayout = True, |
---|
39 | ds = ds, |
---|
40 | ) |
---|
41 | elif psm == 'valid': |
---|
42 | s_id = ds.get('s_id') |
---|
43 | pin = str(ds.get('acco_res_ac_pin')) |
---|
44 | pa = context.portal_accommodation |
---|
45 | code,bed = pa.searchAndReserveBed(s_id,"%s_%s" % (info['sex'],ds.get('student_status'))) |
---|
46 | if code < 0: |
---|
47 | return context.acco_reserve_form(rendered = res, |
---|
48 | psm = bed, |
---|
49 | firstlayout = True, |
---|
50 | lastlayout = True, |
---|
51 | ds = ds, |
---|
52 | ) |
---|
53 | else: |
---|
54 | return context.acco_reserve_form(rendered = res, |
---|
55 | psm = "successfully reserved bed %s" % bed, |
---|
56 | firstlayout = True, |
---|
57 | lastlayout = True, |
---|
58 | ds = ds, |
---|
59 | ) |
---|
60 | |
---|
61 | |
---|