[629] | 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 | |
---|
[635] | 11 | info = context.getStudentInfo() |
---|
[629] | 12 | validate = REQUEST.has_key("cpsdocument_create_button") |
---|
| 13 | |
---|
| 14 | lt = context.portal_layouts |
---|
| 15 | pr = context.portal_registration |
---|
[639] | 16 | session = current.year() |
---|
| 17 | acco_id = 'Acco_%s' % session |
---|
| 18 | info = context.getStudentInfo() |
---|
| 19 | student = info['student'] |
---|
| 20 | if info['acco']: |
---|
| 21 | return student.hostal_reservation_slip() |
---|
[629] | 22 | res,psm,ds = lt.renderLayout(layout_id= 'student_acco_reserve', |
---|
| 23 | schema_id= 'student_acco_reserve', |
---|
| 24 | context=context, |
---|
| 25 | mapping=validate and REQUEST, |
---|
| 26 | ob={}, |
---|
| 27 | layout_mode='create', |
---|
[635] | 28 | formaction = "reserve_acco", |
---|
[629] | 29 | button = "book Bed", |
---|
| 30 | ) |
---|
| 31 | if psm == 'invalid': |
---|
[636] | 32 | return context.reserve_acco_form(rendered = res, |
---|
[635] | 33 | #psm = "Please correct your input.", |
---|
| 34 | psm = "%s, %s" % (psm,ds), |
---|
[629] | 35 | firstlayout = True, |
---|
| 36 | lastlayout = True, |
---|
| 37 | ds = ds, |
---|
| 38 | ) |
---|
| 39 | elif psm == '': |
---|
[636] | 40 | return context.reserve_acco_form(rendered = res, |
---|
[629] | 41 | psm = None, |
---|
| 42 | firstlayout = True, |
---|
| 43 | lastlayout = True, |
---|
| 44 | ds = ds, |
---|
| 45 | ) |
---|
| 46 | elif psm == 'valid': |
---|
| 47 | s_id = ds.get('s_id') |
---|
[635] | 48 | pin = str(ds.get('acco_res_ac_pin')) |
---|
| 49 | pa = context.portal_accommodation |
---|
| 50 | code,bed = pa.searchAndReserveBed(s_id,"%s_%s" % (info['sex'],ds.get('student_status'))) |
---|
[639] | 51 | if code < -10: |
---|
[636] | 52 | return context.reserve_acco_form(rendered = res, |
---|
[635] | 53 | psm = bed, |
---|
| 54 | firstlayout = True, |
---|
| 55 | lastlayout = True, |
---|
| 56 | ds = ds, |
---|
| 57 | ) |
---|
[639] | 58 | student.invokeFactory('StudentAccommodation',acco_id) |
---|
| 59 | acco = getattr(student,acco_id) |
---|
| 60 | ds['acco_res_date'] = current |
---|
| 61 | ds['bed'] = bed |
---|
| 62 | ds['session'] = session |
---|
| 63 | acco.getContent().edit(mapping=ds) |
---|
| 64 | return student.hostal_reservation_slip() |
---|
| 65 | return context.reserve_acco_form(rendered = res, |
---|
[635] | 66 | psm = "successfully reserved bed %s" % bed, |
---|
| 67 | firstlayout = True, |
---|
| 68 | lastlayout = True, |
---|
| 69 | ds = ds, |
---|
| 70 | ) |
---|
[629] | 71 | |
---|