Changeset 3406
- Timestamp:
- 2 Apr 2008, 07:16:08 (17 years ago)
- Location:
- WAeUP_SRP/base
- Files:
-
- 1 added
- 1 deleted
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
WAeUP_SRP/base/Accommodation.py
r3043 r3406 203 203 psm = "Not a reserved bed" 204 204 break 205 if bed_brain.student :205 if bed_brain.student and bed_brain.student != NOT_OCCUPIED: 206 206 psm = "Bed %s already reserved for %s" % (bid,bed_brain.student) 207 207 break -
WAeUP_SRP/base/WAeUPTables.py
r3362 r3406 489 489 490 490 def searchAndReserveBed(self, student_id,bed_type): ###( 491 #records = self.searchResults({'student' : student_id}) 492 #import pdb;pdb.set_trace() 491 logger = logging.getLogger('WAeUPTables.AccommodationTable.searchAndReserveBed') 493 492 records = self.evalAdvancedQuery(Eq('student',student_id)) 494 if len(records) > 0: 495 return -1,"Student with Id %s already booked bed %s." % (student_id,records[0].bed) 496 497 #records = [r for r in self.searchResults({'bed_type' : bed_type}) if not r.student] 493 if len(records) == 1: 494 #return -1,"Student with Id %s already booked bed %s." % (student_id,records[0].bed) 495 logger.info('%s found (reserved) bed %s' % (student_id,records[0].bed)) 496 return -1,records[0].bed 497 elif len(records) > 1: 498 logger.info('%s found more than one (reserved) bed' % (student_id)) 499 return -3,'more than one bed' 498 500 query = Eq('bed_type',bed_type) & Eq('student',NOT_OCCUPIED) 499 501 records = self.evalAdvancedQuery(query,sortSpecs=('sort_id','bed')) 500 502 if len(records) == 0: 501 return -2,"No bed available" 503 logger.info('No bed %s available for %s' % (bed_type,student_id)) 504 return -2,"no bed" 502 505 rec = records[0] 503 506 self.modifyRecord(bed=rec.bed,student=student_id) 504 s_logger = logging.getLogger('WAeUPTables.AccommodationTable.searchAndReserveBed') 505 s_logger.info('%s reserved bed %s' % (student_id,rec.bed)) 507 logger.info('%s booked bed %s' % (student_id,rec.bed)) 506 508 return 1,rec.bed 507 509 ###) -
WAeUP_SRP/base/WAeUPTool.py
r3391 r3406 1175 1175 """return Hall Info""" 1176 1176 info = {} 1177 hall,block,room,letter = bed.split('_') 1177 bedsplit = bed.split('_') 1178 if len(bedsplit) == 4: 1179 hall,block,room,letter = bed.split('_') 1180 else: 1181 info['maintenance_code'] = 'None' 1182 return info 1178 1183 res = ZCatalog.searchResults(self.portal_catalog_real,portal_type="AccoHall",id=hall) 1179 1184 if res and len(res) == 1: -
WAeUP_SRP/base/skins/waeup_accommodation/change_bed.py
r3206 r3406 43 43 psm = 'No bed allocated for %s' % (student_id) 44 44 logger.info(psm) 45 break 46 allocated_bed = res[0] 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='Bed change for %s failed, no free bed in category %s.' % (student_id,status) 57 logger.info(psm) 58 break 59 beds.modifyRecord(bed=allocated_bed.bed,student=beds.not_occupied) 60 logger.info('Bed %s released' % (allocated_bed.bed)) 45 pass 46 #break 47 elif res[0].bed_type.endswith("reserved"): 48 logger.info('found reserved bed %s' % res[0].bed) 49 pass 50 else: 51 allocated_bed = res[0] 52 if allocated_bed.bed_type == status: 53 logger.info('Status %s of %s has not changed.' % (status,student_id)) 54 psm='Student status has not changed!' 55 break 56 #return redirect("%s/%s/%s/waeup_document_view?portal_status_message=%s" % (students.absolute_url(),student_id,info['acco_id'],psm)) 57 logger.info('Bed status %s of %s has changed to %s.' % (allocated_bed.bed_type,student_id,status)) 58 query = Eq('bed_type',status) & Eq('student',context.portal_accommodation.not_occupied) 59 records = context.portal_accommodation.evalAdvancedQuery(query) 60 if len(records) < 1: 61 psm='Bed change for %s failed, no free bed in category %s.' % (student_id,status) 62 logger.info(psm) 63 break 64 beds.modifyRecord(bed=allocated_bed.bed,student=beds.not_occupied) 65 logger.info('Bed %s released' % (allocated_bed.bed)) 61 66 code,bed = beds.searchAndReserveBed(student_id,status) 62 if code > 0:67 if code > -2: 63 68 d = {} 64 69 d['bed'] = bed … … 72 77 psm='Bed changed!' 73 78 break 74 #return redirect("%s/%s/%s/waeup_document_view?portal_status_message=%s" % (students.absolute_url(),student_id,info['acco_id'],psm))75 #acco_doc = info['acco_doc']76 #acco_doc.edit(mapping={'bed':"-- cancelled by officer due to failed bed change request --"})77 79 logger.info('Bed change for %s failed, code = %s' % (student_id,code)) 78 #logger.info('%s cancelled booking of bed %s by %s' % (member,bed,student_id))79 80 psm='Bed change failed!' 81 break 80 82 return redirect("%s/%s/%s/waeup_document_view?portal_status_message=%s" % (students.absolute_url(),student_id,info['acco_id'],psm)) 81 83 -
WAeUP_SRP/base/skins/waeup_accommodation/release_bed.py
r3049 r3406 44 44 acco_cat.modifyRecord(bed=allocated_bed.bed,student=acco_cat.not_occupied) 45 45 acco_doc = context.getContent() 46 acco_doc.edit(mapping={'bed':"-- cancelled by section officer --" })46 acco_doc.edit(mapping={'bed':"-- cancelled by section officer --",'acco_maint_fee':""}) 47 47 logger.info('%s released bed of %s' % (member_id,student_id)) 48 48 return redirect("%s" % (context.absolute_url())) -
WAeUP_SRP/base/skins/waeup_student/reserve_accommodation.py
r3126 r3406 108 108 break 109 109 if code == -1: 110 return context.accommodation_edit_form(rendered = res, 111 psm = "%s" % bed, 112 mode = mode, 113 ds = ds, 114 ) 110 break 111 #return context.accommodation_edit_form(rendered = res, 112 # psm = "%s" % bed, 113 # mode = mode, 114 # ds = ds, 115 # ) 115 116 elif code == -2: 116 117 return context.accommodation_edit_form(rendered = res,
Note: See TracChangeset for help on using the changeset viewer.