[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 5616 2010-12-27 10:18:18Z 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, %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 | )
|
---|
| 64 | elif psm == '':
|
---|
| 65 | return context.pay_accommodation_form(rendered = res,
|
---|
| 66 | psm = None,
|
---|
| 67 | mode = mode,
|
---|
| 68 | ds = ds,
|
---|
| 69 | )
|
---|
| 70 | elif psm == 'valid':
|
---|
| 71 | pass
|
---|
| 72 |
|
---|
| 73 | data={}
|
---|
| 74 | data['acco_maint_sc_pin'] = ds['acco_maint_sc_pin']
|
---|
| 75 | data['acco_maint_date'] = current
|
---|
| 76 | data['catkey'] =student_id + '|' + session
|
---|
| 77 | data['reservation_status'] = 'maintenance_fee_paid'
|
---|
| 78 |
|
---|
| 79 | #set_trace()
|
---|
| 80 | context.accommodation_catalog.modifyRecord(**data)
|
---|
| 81 |
|
---|
| 82 | return context.REQUEST.RESPONSE.redirect("%s/accommodations" % student.absolute_url())
|
---|
| 83 |
|
---|