Changeset 3156 for WAeUP_SRP/base/skins/waeup_accommodation/change_bed.py
- Timestamp:
- 13 Feb 2008, 16:33:21 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
WAeUP_SRP/base/skins/waeup_accommodation/change_bed.py
r3151 r3156 13 13 """ 14 14 import logging 15 from Products.AdvancedQuery import Eq, Between, Le,In 16 15 17 logger = logging.getLogger('Skins.change_bed') 16 17 18 request = context.REQUEST 18 19 redirect = request.RESPONSE.redirect … … 38 39 res = beds(student=student_id) 39 40 status = info['student_status'] 40 if len(res) == 0: 41 logger.info('No bed allocated for %s' % (student_id)) 42 #return redirect("%s/%s" % (students.absolute_url(),student_id)) 43 else: 41 while True: 42 if len(res) == 0: 43 psm = 'No bed allocated for %s' % (student_id) 44 logger.info(psm) 45 break 44 46 allocated_bed = res[0] 45 code,bed = beds.searchAndReserveBed(student_id,status) 46 if code > 0: 47 if res: 48 if allocated_bed.bed_type == status: 49 logger.info('Status %s of %s has not changed' % (status,student_id)) 50 psm='Student status has not changed!' 51 return redirect("%s/%s/%s/waeup_document_view?portal_status_message=%s" % (students.absolute_url(),student_id,info['acco_id'],psm)) 52 logger.info('Bed status %s of %s has changed to %s' % (allocated_bed.bed_type,student_id,status)) 53 beds.modifyRecord(bed=allocated_bed.bed,student=beds.not_occupied) 54 logger.info('Bed %s released' % (allocated_bed.bed)) 55 d = {} 56 d['bed'] = bed 57 d['student_status'] = status 58 acco_info = context.waeup_tool.getHallInfo(bed) 59 d['acco_maint_code'] = acco_info.get('maintenance_code') 60 d['acco_maint_fee'] = acco_info.get('maintenance_fee') 61 acco_doc = info['acco_doc'] 62 acco_doc.edit(mapping=d) 63 logger.info('Bed %s allocated to %s' % (bed,student_id)) 64 psm='Bed changed!' 65 return redirect("%s/%s/%s/waeup_document_view?portal_status_message=%s" % (students.absolute_url(),student_id,info['acco_id'],psm)) 66 #acco_doc = info['acco_doc'] 67 #acco_doc.edit(mapping={'bed':"-- cancelled by officer due to failed bed change request --"}) 68 logger.info('New bed allocation for %s failed, code = %s' % (student_id,code)) 69 #logger.info('%s cancelled booking of bed %s by %s' % (member,bed,student_id)) 70 psm='Bed change failed!' 47 if allocated_bed.bed_type == status: 48 logger.info('Status %s of %s has not changed' % (status,student_id)) 49 psm='Student status has not changed!' 50 break 51 #return redirect("%s/%s/%s/waeup_document_view?portal_status_message=%s" % (students.absolute_url(),student_id,info['acco_id'],psm)) 52 logger.info('Bed status %s of %s has changed to %s' % (allocated_bed.bed_type,student_id,status)) 53 query = Eq('bed_type',status) & Eq('student',context.portal_accommodation.not_occupied) 54 records = context.portal_accommodation.evalAdvancedQuery(query) 55 if len(records) < 1: 56 psm=''New bed allocation for %s failed, No bed free in category %s' % (student_id,status) 57 logger.info(psm) 58 psm='Bed change failed!' 59 break 60 beds.modifyRecord(bed=allocated_bed.bed,student=beds.not_occupied) 61 logger.info('Bed %s released' % (allocated_bed.bed)) 62 code,bed = beds.searchAndReserveBed(student_id,status) 63 if code > 0: 64 d = {} 65 d['bed'] = bed 66 d['student_status'] = status 67 acco_info = context.waeup_tool.getHallInfo(bed) 68 d['acco_maint_code'] = acco_info.get('maintenance_code') 69 d['acco_maint_fee'] = acco_info.get('maintenance_fee') 70 acco_doc = info['acco_doc'] 71 acco_doc.edit(mapping=d) 72 logger.info('Bed %s allocated to %s' % (bed,student_id)) 73 psm='Bed changed!' 74 break 75 #return redirect("%s/%s/%s/waeup_document_view?portal_status_message=%s" % (students.absolute_url(),student_id,info['acco_id'],psm)) 76 #acco_doc = info['acco_doc'] 77 #acco_doc.edit(mapping={'bed':"-- cancelled by officer due to failed bed change request --"}) 78 logger.info('New bed allocation for %s failed, code = %s' % (student_id,code)) 79 #logger.info('%s cancelled booking of bed %s by %s' % (member,bed,student_id)) 80 psm='Bed change failed!' 71 81 return redirect("%s/%s/%s/waeup_document_view?portal_status_message=%s" % (students.absolute_url(),student_id,info['acco_id'],psm)) 72 82
Note: See TracChangeset for help on using the changeset viewer.