Changeset 2857 for WAeUP_SRP/base/skins/waeup_accommodation
- Timestamp:
- 4 Dec 2007, 16:28:13 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
WAeUP_SRP/base/skins/waeup_accommodation/reserve_accommodation.py
r2454 r2857 1 ## Script (Python) "reserve_accommodation.py" 2 ##bind container=container 3 ##bind context=context 4 ##bind namespace= 5 ##bind script=script 6 ##bind subpath=traverse_subpath 1 7 ##parameters=REQUEST 2 8 # $Id$ … … 4 10 process the the accommodation reservation 5 11 """ 12 try: 13 from Products.zdb import set_trace 14 except: 15 def set_trace(): 16 pass 6 17 import DateTime 7 18 current = DateTime.DateTime() … … 26 37 return context.REQUEST.RESPONSE.redirect("%s/no_booking_allowed" % info['student'].absolute_url()) 27 38 student = info['student'] 39 student_id = info['student_id'] 28 40 acco_id = info['acco_id'] 29 session = info['session'][1] 41 #session = info['session'][1] 42 session = info['session'] 30 43 #session = acco_id[-4:] 31 44 validate = REQUEST.has_key("cpsdocument_create_button") 32 45 if info.has_key('acco') and info['acco']: 33 46 validate = REQUEST.has_key("cpsdocument_edit_button") 34 if info[' acco_review_state'] == "maintenance_fee_paid":47 if info['maintenance_paid']: 35 48 return context.REQUEST.RESPONSE.redirect("%s/accommodation_view" % info['acco'].absolute_url()) 49 elif info['online_payment']: 50 return context.REQUEST.RESPONSE.redirect("%s/pay_interswitch_acco?paytype=HOM" % info['student'].absolute_url()) 36 51 else: 37 52 mode = 'edit' … … 61 76 else: 62 77 psm = "Error in data, unable to reserve bed." 63 return context.accommodation_ pin_edit_form(rendered = res,78 return context.accommodation_edit_form(rendered = res, 64 79 psm = psm, 65 80 #psm = "%s, %s" % (psm,ds), … … 68 83 ) 69 84 elif psm == '': 70 return context.accommodation_ pin_edit_form(rendered = res,85 return context.accommodation_edit_form(rendered = res, 71 86 psm = None, 72 87 mode = mode, … … 74 89 ) 75 90 elif psm == 'valid': 76 s_id = ds.get('s_id')77 91 if mode == 'create': 92 set_trace() 78 93 pin = str(ds.get('acco_res_sc_pin')) 79 pa = context.portal_accommodation80 already = pa(student=s_id)81 if not already:82 code,bed = pa.searchAndReserveBed(s_id,"%s" % (info['student_status']))83 #code,bed = pa.searchAndReserveBed(s_id,"%s_%s" % (info['sex'],ds.get('student_status')))94 code,bed = context.portal_accommodation.searchAndReserveBed(student_id, 95 "%s" % (info['student_status'])) 96 while True: 97 if code == 1: 98 break 84 99 if code == -1: 85 return context.accommodation_ pin_edit_form(rendered = res,86 psm = "%s" % bed,87 mode = mode,88 ds = ds,89 )100 return context.accommodation_edit_form(rendered = res, 101 psm = "%s" % bed, 102 mode = mode, 103 ds = ds, 104 ) 90 105 elif code == -2: 91 return context.accommodation_pin_edit_form(rendered = res, 92 psm = "No bed available. Your category is already fully booked.", 93 mode = mode, 94 ds = ds, 95 ) 96 else: 97 bed = already[0].bed 106 return context.accommodation_edit_form(rendered = res, 107 psm = "No bed available. Your category is already fully booked.", 108 mode = mode, 109 ds = ds, 110 ) 111 else: # unknown error 112 return context.accommodation_edit_form(rendered = res, 113 psm = "Unexpected Error!", 114 mode = mode, 115 ds = ds, 116 ) 98 117 student.invokeFactory('StudentAccommodation',acco_id) 99 acco = getattr(student,acco_id) 100 acco_info = context.waeup_tool.getHallInfo(bed) 101 ds.set('acco_maint_code', acco_info.get('maintenance_code')) 102 ds.set('acco_maint_fee', acco_info.get('maintenance_fee')) 118 hall_info = context.waeup_tool.getHallInfo(bed) 119 ds.set('acco_maint_code', hall_info.get('maintenance_code')) 120 ds.set('acco_maint_fee', hall_info.get('maintenance_fee')) 103 121 ds.set('acco_res_date', current) 104 122 ds.set('bed', bed) 105 123 ds.set('session', session) 106 124 ds.set('student_status',info['student_status']) 125 acco = getattr(student,acco_id) 107 126 acco.getContent().edit(mapping=ds) 108 127 #wftool.doActionFor(acco,'pay_maintenance_fee',dest_container=acco)
Note: See TracChangeset for help on using the changeset viewer.