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

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

Implement second part of new accommodation allocation module. This part contains the new scripts and page templates needed. See ReadMe?.txt for further instructions.

  • Property svn:keywords set to Id
File size: 2.8 KB
Line 
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 5616 2010-12-27 10:18:18Z 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, %s' % (member_id,info['error'] ))
57    logger.info('%s entered invalid data' % (member_id))
58    psm = "Please correct your input."
59    return context.pay_accommodation_form(rendered = res,
60                                 psm = psm,
61                                 mode = mode,
62                                 ds = ds,
63                                 )
64elif psm == '':
65    return context.pay_accommodation_form(rendered = res,
66                                 psm = None,
67                                 mode = mode,
68                                 ds = ds,
69                                 )
70elif psm == 'valid':
71    pass
72
73data={}
74data['acco_maint_sc_pin'] = ds['acco_maint_sc_pin']
75data['acco_maint_date'] = current
76data['catkey'] =student_id + '|' + session
77data['reservation_status'] = 'maintenance_fee_paid'
78
79#set_trace()
80context.accommodation_catalog.modifyRecord(**data)
81
82return context.REQUEST.RESPONSE.redirect("%s/accommodations" % student.absolute_url())
83
Note: See TracBrowser for help on using the repository browser.