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

Last change on this file since 653 was 652, checked in by joachim, 18 years ago

cleanup naming in accommodation part II

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