source: WAeUP_SRP/trunk/skins/waeup_student/reserve_accommodation.py @ 663

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

accomodation_view now also shows up after booking
title changed

File size: 2.9 KB
Line 
1##parameters=REQUEST
2# $Id: apply_admission.py 543 2006-09-24 07:44:32Z henrik $
3"""
4process the Application Form
5return html renderer + psm
6"""
7import DateTime
8current = DateTime.DateTime()
9pr = context.portal_registration
10wftool = context.portal_workflow
11
12info = context.getStudentInfo()
13validate = REQUEST.has_key("cpsdocument_create_button")
14
15lt = context.portal_layouts
16pr = context.portal_registration
17session = current.year()
18acco_id = 'accommodation_%s' % session
19info = context.getStudentInfo()
20student = info['student']
21if info['acco']:
22    return context.REQUEST.RESPONSE.redirect("%s" % info['acco'].absolute_url())
23res,psm,ds = lt.renderLayout(layout_id= 'student_accommodation_fe',
24                      schema_id= 'student_accommodation_fe',
25                      context=context,
26                      mapping=validate and REQUEST,
27                      ob={},
28                      layout_mode='create',
29                      formaction = "reserve_accommodation",
30                      button = "Book",
31                      )
32if psm == 'invalid':
33    return context.accommodation_pin_form(rendered = res,
34                                 #psm = "Please correct your input.",
35                                 psm = "%s, %s" % (psm,ds),
36                                 firstlayout = True,
37                                 lastlayout = True,
38                                 ds = ds,
39                                 )
40elif psm == '':
41    return context.accommodation_pin_form(rendered = res,
42                                 psm = None,
43                                 firstlayout = True,
44                                 lastlayout = True,
45                                 ds = ds,
46                                 )
47elif psm == 'valid':
48    s_id = ds.get('s_id')
49    pin = str(ds.get('acco_res_ac_pin'))
50
51    pa = context.portal_accommodation
52    code,bed = pa.searchAndReserveBed(s_id,"%s_%s" % (info['sex'],ds.get('student_status')))
53    if code < 0:
54        return context.accommodation_pin_form(rendered = res,
55                                 psm = bed,
56                                 firstlayout = True,
57                                 lastlayout = True,
58                                 ds = ds,
59                                 )
60student.invokeFactory('StudentAccommodation',acco_id)
61acco = getattr(student,acco_id)
62wftool.doActionFor(acco,'open',dest_container=acco)
63ds.set('acco_res_date', current)
64ds.set('bed', bed)
65ds.set('session', session)
66acco.getContent().edit(mapping=ds)
67return context.REQUEST.RESPONSE.redirect("%s/accommodation_view" % student.absolute_url())
68##return context.accommodation_pin_form(rendered = res,
69##                                 psm = "successfully reserved bed %s" % bed,
70##                                 firstlayout = True,
71##                                 lastlayout = True,
72##                                 ds = ds,
73##                                 )
74
Note: See TracBrowser for help on using the repository browser.