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

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

spelling mistake corrected (maintenance)

File size: 3.8 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") or\
14           REQUEST.has_key("cpsdocument_edit_button")
15
16lt = context.portal_layouts
17pr = context.portal_registration
18session = current.year()
19acco_id = 'accommodation_%s' % session
20info = context.getStudentInfo()
21student = info['student']
22mode = 'create'
23if info.has_key('acco') and info['acco']:
24    if info['acco_review_state'] == "maintenance_fee_payed":
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',
36                      schema_id= 'student_accommodation',
37                      context=context,
38                      mapping=validate and REQUEST,
39                      ob=d,
40                      layout_mode=mode,
41                      formaction = "reserve_accommodation",
42                      button = "Book",
43                      )
44if psm == 'invalid':
45    return context.accommodation_pin_form(rendered = res,
46                                 psm = "Please correct your input.",
47                                 #psm = "%s, %s" % (psm,ds),
48                                 firstlayout = True,
49                                 lastlayout = True,
50                                 ds = ds,
51                                 )
52elif psm == '':
53    return context.accommodation_pin_form(rendered = res,
54                                 psm = None,
55                                 firstlayout = True,
56                                 lastlayout = True,
57                                 ds = ds,
58                                 )
59elif psm == 'valid':
60    s_id = ds.get('s_id')
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,
67                                 psm = bed,
68                                 firstlayout = True,
69                                 lastlayout = True,
70                                 ds = ds,
71                                 )
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)
78        #wftool.doActionFor(acco,'pay_maintenance_fee',dest_container=acco)
79        return context.REQUEST.RESPONSE.redirect("%s/accommodation_view" % student.absolute_url())
80pin = str(ds.get('acco_main_sc_pin'))
81pp = context.portal_pins
82acco = getattr(student,acco_id)
83ds.set('acco_maint_date', current)
84acco.getContent().edit(mapping=ds)
85wftool.doActionFor(acco,'pay_maintenance_fee',dest_container=acco)
86return context.REQUEST.RESPONSE.redirect("%s/accommodation_view" % student.absolute_url())
87
88##return context.accommodation_pin_form(rendered = res,
89##                                 psm = "successfully reserved bed %s" % bed,
90##                                 firstlayout = True,
91##                                 lastlayout = True,
92##                                 ds = ds,
93##                                 )
94
Note: See TracBrowser for help on using the repository browser.