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

Last change on this file since 807 was 805, checked in by joachim, 18 years ago

propset Id

  • Property svn:keywords set to Id
File size: 3.7 KB
RevLine 
[629]1##parameters=REQUEST
[805]2# $Id: reserve_accommodation.py 805 2006-11-09 09:38:29Z joachim $
[629]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()
[742]13validate = REQUEST.has_key("cpsdocument_create_button") or\
14           REQUEST.has_key("cpsdocument_edit_button")
[629]15
16lt = context.portal_layouts
17pr = context.portal_registration
[639]18session = current.year()
[659]19acco_id = 'accommodation_%s' % session
[639]20info = context.getStudentInfo()
21student = info['student']
[742]22mode = 'create'
23if info.has_key('acco') and info['acco']:
[744]24    if info['acco_review_state'] == "maintenance_fee_payed":
[742]25        return context.REQUEST.RESPONSE.redirect("%s/accommodation_view" % info['acco'].absolute_url())
26    else:
27        mode = 'edit'
28d = {}
29if mode == 'edit':
30    info = context.getStudentInfo()
31    d['acco_res_date'] = info['acco_doc'].acco_res_date
32    d['acco_res_sc_pin'] = info['acco_doc'].acco_res_sc_pin
33    d['bed'] = info['acco_doc'].bed
34    d['session'] = info['acco_doc'].session
35res,psm,ds = lt.renderLayout(layout_id= 'student_accommodation_fe',
[686]36                      schema_id= 'student_accommodation',
[629]37                      context=context,
38                      mapping=validate and REQUEST,
[742]39                      ob=d,
40                      layout_mode=mode,
[652]41                      formaction = "reserve_accommodation",
[659]42                      button = "Book",
[629]43                      )
44if psm == 'invalid':
[652]45    return context.accommodation_pin_form(rendered = res,
[701]46                                 psm = "Please correct your input.",
47                                 #psm = "%s, %s" % (psm,ds),
[629]48                                 firstlayout = True,
49                                 lastlayout = True,
50                                 ds = ds,
51                                 )
52elif psm == '':
[652]53    return context.accommodation_pin_form(rendered = res,
[629]54                                 psm = None,
55                                 firstlayout = True,
56                                 lastlayout = True,
57                                 ds = ds,
58                                 )
59elif psm == 'valid':
60    s_id = ds.get('s_id')
[742]61    if mode == 'create':
62        pin = str(ds.get('acco_res_sc_pin'))
63        pa = context.portal_accommodation
64        code,bed = pa.searchAndReserveBed(s_id,"%s_%s" % (info['sex'],ds.get('student_status')))
65        if code < 0:
66            return context.accommodation_pin_form(rendered = res,
[635]67                                 psm = bed,
68                                 firstlayout = True,
69                                 lastlayout = True,
70                                 ds = ds,
71                                 )
[742]72        student.invokeFactory('StudentAccommodation',acco_id)
73        acco = getattr(student,acco_id)
74        ds.set('acco_res_date', current)
75        ds.set('bed', bed)
76        ds.set('session', session)
77        acco.getContent().edit(mapping=ds)
[744]78        #wftool.doActionFor(acco,'pay_maintenance_fee',dest_container=acco)
[742]79        return context.REQUEST.RESPONSE.redirect("%s/accommodation_view" % student.absolute_url())
80pin = str(ds.get('acco_main_sc_pin'))
81pp = context.portal_pins
[639]82acco = getattr(student,acco_id)
[742]83ds.set('acco_maint_date', current)
[639]84acco.getContent().edit(mapping=ds)
[744]85wftool.doActionFor(acco,'pay_maintenance_fee',dest_container=acco)
[660]86return context.REQUEST.RESPONSE.redirect("%s/accommodation_view" % student.absolute_url())
[742]87
[652]88##return context.accommodation_pin_form(rendered = res,
[642]89##                                 psm = "successfully reserved bed %s" % bed,
90##                                 firstlayout = True,
91##                                 lastlayout = True,
92##                                 ds = ds,
93##                                 )
[629]94
Note: See TracBrowser for help on using the repository browser.