[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 | """
|
---|
| 10 | process the the accommodation fee payment
|
---|
| 11 | """
|
---|
| 12 | try:
|
---|
| 13 | from Products.zdb import set_trace
|
---|
| 14 | except:
|
---|
| 15 | def set_trace():
|
---|
| 16 | pass
|
---|
| 17 | import DateTime
|
---|
| 18 | current = DateTime.DateTime()
|
---|
| 19 | pr = context.portal_registration
|
---|
| 20 | wftool = context.portal_workflow
|
---|
| 21 | lt = context.portal_layouts
|
---|
| 22 | info = context.getAccommodationStatus()
|
---|
| 23 |
|
---|
| 24 | import logging
|
---|
| 25 | logger = logging.getLogger('Skins.pay_accommodation')
|
---|
| 26 |
|
---|
| 27 | if 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())
|
---|
| 36 | student = info['student']
|
---|
| 37 | student_id = info['student_id']
|
---|
| 38 | acco_id = info['acco_id']
|
---|
| 39 | session = info['session']
|
---|
| 40 | mode = 'edit'
|
---|
| 41 | validate = REQUEST.has_key("cpsdocument_edit_button")
|
---|
| 42 | button = 'Submit'
|
---|
| 43 |
|
---|
| 44 |
|
---|
| 45 | res,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 |
|
---|
| 54 | if 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 | )
|
---|
| 63 | elif psm == '':
|
---|
| 64 | return context.pay_accommodation_form(rendered = res,
|
---|
| 65 | psm = None,
|
---|
| 66 | mode = mode,
|
---|
| 67 | ds = ds,
|
---|
| 68 | )
|
---|
| 69 | elif psm == 'valid':
|
---|
| 70 | pass
|
---|
| 71 |
|
---|
| 72 | data={}
|
---|
| 73 | data['acco_maint_sc_pin'] = ds['acco_maint_sc_pin']
|
---|
| 74 | data['acco_maint_date'] = current
|
---|
| 75 | data['catkey'] =student_id + '|' + session
|
---|
| 76 | data['reservation_status'] = 'maintenance_fee_paid'
|
---|
| 77 |
|
---|
| 78 | context.accommodation_catalog.modifyRecord(**data)
|
---|
| 79 |
|
---|
[5621] | 80 | logger.info('%s paid accommodation in session %s' % (student_id,session))
|
---|
| 81 |
|
---|
[5616] | 82 | return context.REQUEST.RESPONSE.redirect("%s/accommodations" % student.absolute_url())
|
---|
| 83 |
|
---|