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

Last change on this file since 967 was 952, checked in by joachim, 18 years ago

loading of cps_portlets by generic_setup

  • Property svn:keywords set to Id
File size: 3.7 KB
RevLine 
[629]1##parameters=REQUEST
[805]2# $Id: reserve_accommodation.py 952 2006-11-27 20:47:26Z joachim $
[629]3"""
4process the Application Form
5return html renderer + psm
6"""
7import DateTime
[952]8
[629]9current = DateTime.DateTime()
10pr = context.portal_registration
[659]11wftool = context.portal_workflow
[629]12
[635]13info = context.getStudentInfo()
[821]14validate = REQUEST.has_key("cpsdocument_create_button")
15#           REQUEST.has_key("cpsdocument_edit_button")
[629]16
17lt = context.portal_layouts
18pr = context.portal_registration
[639]19session = current.year()
[659]20acco_id = 'accommodation_%s' % session
[639]21info = context.getStudentInfo()
22student = info['student']
[742]23mode = 'create'
[942]24
25if info['review_state'] != 'cleared_and_validated':
26    return context.REQUEST.RESPONSE.redirect("%s/no_booking_allowed" % info['student'].absolute_url())
27
[742]28if info.has_key('acco') and info['acco']:
[821]29    validate = REQUEST.has_key("cpsdocument_edit_button")
[835]30    if info['acco_review_state'] == "maintenance_fee_paid":
[742]31        return context.REQUEST.RESPONSE.redirect("%s/accommodation_view" % info['acco'].absolute_url())
32    else:
33        mode = 'edit'
34d = {}
[833]35button = "Book"
[742]36if mode == 'edit':
37    info = context.getStudentInfo()
38    d['acco_res_date'] = info['acco_doc'].acco_res_date
39    d['acco_res_sc_pin'] = info['acco_doc'].acco_res_sc_pin
[821]40    d['student_status'] = info['acco_doc'].student_status
[742]41    d['bed'] = info['acco_doc'].bed
42    d['session'] = info['acco_doc'].session
[821]43    button = "Pay Maintainance Fee"
[742]44res,psm,ds = lt.renderLayout(layout_id= 'student_accommodation_fe',
[686]45                      schema_id= 'student_accommodation',
[629]46                      context=context,
47                      mapping=validate and REQUEST,
[742]48                      ob=d,
49                      layout_mode=mode,
[652]50                      formaction = "reserve_accommodation",
[821]51                      button = button
[629]52                      )
53if psm == 'invalid':
[849]54    return context.accommodation_pin_edit_form(rendered = res,
[892]55                                 psm = "Please correct your input!",
[701]56                                 #psm = "%s, %s" % (psm,ds),
[821]57                                 mode = mode,
[629]58                                 ds = ds,
59                                 )
60elif psm == '':
[849]61    return context.accommodation_pin_edit_form(rendered = res,
[629]62                                 psm = None,
[821]63                                 mode = mode,
[629]64                                 ds = ds,
65                                 )
66elif psm == 'valid':
67    s_id = ds.get('s_id')
[742]68    if mode == 'create':
69        pin = str(ds.get('acco_res_sc_pin'))
70        pa = context.portal_accommodation
71        code,bed = pa.searchAndReserveBed(s_id,"%s_%s" % (info['sex'],ds.get('student_status')))
72        if code < 0:
[855]73            return context.accommodation_pin_edit_form(rendered = res,
[635]74                                 psm = bed,
[821]75                                 mode = mode,
[635]76                                 ds = ds,
77                                 )
[742]78        student.invokeFactory('StudentAccommodation',acco_id)
79        acco = getattr(student,acco_id)
[828]80        acco_info = context.waeup_tool.getAccommodationInfo(bed)
81        ds.set('acco_maint_code', acco_info.get('maintenance_code'))
82        ds.set('acco_maint_fee', acco_info.get('maintenance_fee'))
[742]83        ds.set('acco_res_date', current)
84        ds.set('bed', bed)
85        ds.set('session', session)
86        acco.getContent().edit(mapping=ds)
[744]87        #wftool.doActionFor(acco,'pay_maintenance_fee',dest_container=acco)
[856]88        return context.REQUEST.RESPONSE.redirect("%s/reserve_accommodation" % student.absolute_url())
[742]89pin = str(ds.get('acco_main_sc_pin'))
90pp = context.portal_pins
[639]91acco = getattr(student,acco_id)
[742]92ds.set('acco_maint_date', current)
[639]93acco.getContent().edit(mapping=ds)
[744]94wftool.doActionFor(acco,'pay_maintenance_fee',dest_container=acco)
[660]95return context.REQUEST.RESPONSE.redirect("%s/accommodation_view" % student.absolute_url())
Note: See TracBrowser for help on using the repository browser.