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

Last change on this file since 727 was 701, checked in by joachim, 18 years ago

created new layout-method layout_enter_access_code.pt
and use this for application create and accommodation create. Actually now
layout_application_create is now no longer neccessary.

File size: 2.9 KB
RevLine 
[629]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
[659]10wftool = context.portal_workflow
[629]11
[635]12info = context.getStudentInfo()
[629]13validate = REQUEST.has_key("cpsdocument_create_button")
14
15lt = context.portal_layouts
16pr = context.portal_registration
[639]17session = current.year()
[659]18acco_id = 'accommodation_%s' % session
[639]19info = context.getStudentInfo()
20student = info['student']
21if info['acco']:
[668]22    return context.REQUEST.RESPONSE.redirect("%s/accommodation_view" % info['acco'].absolute_url())
[686]23res,psm,ds = lt.renderLayout(layout_id= 'student_accommodation',
24                      schema_id= 'student_accommodation',
[629]25                      context=context,
26                      mapping=validate and REQUEST,
27                      ob={},
28                      layout_mode='create',
[652]29                      formaction = "reserve_accommodation",
[659]30                      button = "Book",
[629]31                      )
32if psm == 'invalid':
[652]33    return context.accommodation_pin_form(rendered = res,
[701]34                                 psm = "Please correct your input.",
35                                 #psm = "%s, %s" % (psm,ds),
[629]36                                 firstlayout = True,
37                                 lastlayout = True,
38                                 ds = ds,
39                                 )
40elif psm == '':
[652]41    return context.accommodation_pin_form(rendered = res,
[629]42                                 psm = None,
43                                 firstlayout = True,
44                                 lastlayout = True,
45                                 ds = ds,
46                                 )
47elif psm == 'valid':
48    s_id = ds.get('s_id')
[635]49    pin = str(ds.get('acco_res_ac_pin'))
[659]50
[635]51    pa = context.portal_accommodation
52    code,bed = pa.searchAndReserveBed(s_id,"%s_%s" % (info['sex'],ds.get('student_status')))
[642]53    if code < 0:
[652]54        return context.accommodation_pin_form(rendered = res,
[635]55                                 psm = bed,
56                                 firstlayout = True,
57                                 lastlayout = True,
58                                 ds = ds,
59                                 )
[639]60student.invokeFactory('StudentAccommodation',acco_id)
61acco = getattr(student,acco_id)
[659]62wftool.doActionFor(acco,'open',dest_container=acco)
[642]63ds.set('acco_res_date', current)
64ds.set('bed', bed)
65ds.set('session', session)
[639]66acco.getContent().edit(mapping=ds)
[660]67return context.REQUEST.RESPONSE.redirect("%s/accommodation_view" % student.absolute_url())
[652]68##return context.accommodation_pin_form(rendered = res,
[642]69##                                 psm = "successfully reserved bed %s" % bed,
70##                                 firstlayout = True,
71##                                 lastlayout = True,
72##                                 ds = ds,
73##                                 )
[629]74
Note: See TracBrowser for help on using the repository browser.