source: WAeUP_SRP/trunk/skins/waeup_accommodation/pay_accommodation.py @ 16250

Last change on this file since 16250 was 5621, checked in by Henrik Bettermann, 14 years ago

Further improvements for new accommodation booking.

  • Property svn:keywords set to Id
File size: 2.8 KB
RevLine 
[5616]1## Script (Python) "pay_accommodation.py"
2##bind container=container
3##bind context=context
4##bind namespace=
5##bind script=script
6##bind subpath=traverse_subpath
7##parameters=REQUEST
8# $Id: pay_accommodation.py 5621 2010-12-28 08:53:23Z henrik $
9"""
10process the the accommodation fee payment
11"""
12try:
13    from Products.zdb import set_trace
14except:
15    def set_trace():
16        pass
17import DateTime
18current = DateTime.DateTime()
19pr = context.portal_registration
20wftool = context.portal_workflow
21lt = context.portal_layouts
22info = context.getAccommodationStatus()
23
24import logging
25logger = logging.getLogger('Skins.pay_accommodation')
26
27if info is None:
28    member_id = str(context.portal_membership.getAuthenticatedMember())
29    logger.info('%s tried to pay accommodation' % (member_id))
30    return context.REQUEST.RESPONSE.redirect("%s/srp_invalid_access" % context.portal_url())
31
32#if info['booking_disabled']:
33#    return context.REQUEST.RESPONSE.redirect("%s/booking_disabled" % info['student'].absolute_url())
34#if not info['booking_allowed']:
35#    return context.REQUEST.RESPONSE.redirect("%s/no_booking_allowed" % info['student'].absolute_url())
36student = info['student']
37student_id = info['student_id']
38acco_id = info['acco_id']
39session = info['session']
40mode = 'edit'
41validate = REQUEST.has_key("cpsdocument_edit_button")
42button = 'Submit'
43
44
45res,psm,ds = lt.renderLayout(layout_id= 'student_accommodation_fe',
46                      schema_id= 'student_accommodation',
47                      context=context,
48                      mapping=validate and REQUEST,
49                      ob=info,
50                      layout_mode=mode,
51                      formaction = "pay_accommodation",
52                      button = button)
53
54if psm == 'invalid':
55    member_id = str(context.portal_membership.getAuthenticatedMember())
56    logger.info('%s entered invalid data' % (member_id))
57    psm = "Please correct your input."
58    return context.pay_accommodation_form(rendered = res,
59                                 psm = psm,
60                                 mode = mode,
61                                 ds = ds,
62                                 )
63elif psm == '':
64    return context.pay_accommodation_form(rendered = res,
65                                 psm = None,
66                                 mode = mode,
67                                 ds = ds,
68                                 )
69elif psm == 'valid':
70    pass
71
72data={}
73data['acco_maint_sc_pin'] = ds['acco_maint_sc_pin']
74data['acco_maint_date'] = current
75data['catkey'] =student_id + '|' + session
76data['reservation_status'] = 'maintenance_fee_paid'
77
78context.accommodation_catalog.modifyRecord(**data)
79
[5621]80logger.info('%s paid accommodation in session %s' % (student_id,session))
81
[5616]82return context.REQUEST.RESPONSE.redirect("%s/accommodations" % student.absolute_url())
83
Note: See TracBrowser for help on using the repository browser.