Changeset 3043
- Timestamp:
- 24 Jan 2008, 18:02:36 (17 years ago)
- Location:
- WAeUP_SRP/base
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
WAeUP_SRP/base/Accommodation.py
r2867 r3043 38 38 generate the free Bedslist. 39 39 """ 40 freelist = self.portal_accommodation40 bed_list = self.portal_accommodation 41 41 l = self.portal_catalog({'meta_type': "AccoHall"}) 42 42 halls = [] 43 43 generated = [] 44 44 generated.append('"Bed","BedType","Student"' % vars()) 45 modyfied = [] 46 modyfied.append('"Bed","BedType","Student"' % vars()) 45 47 beds_generated = [] 46 48 for h in l: … … 52 54 hall_gen['name'] = hall.Title 53 55 count = 0 56 modyfied_count = 0 54 57 reserved = [(r.split('/')[0],int(r.split('/')[1])) for r in re.split(',|\.| ',hall_doc.reserved_rooms) 55 58 if r] 56 59 #for block in range(1,int(hall_doc.nr_of_blocks)+1): 57 60 # for block in 'ABCDEFGHIJ'[:int(hall_doc.nr_of_blocks)]: 58 if set(hall_doc.blocks_for_female).intersection(set(hall_doc.blocks_for_male)): 61 blocks_for_female = getattr(hall_doc,'blocks_for_female',[]) 62 blocks_for_male = getattr(hall_doc,'blocks_for_male',[]) 63 beds_for_fresh = getattr(hall_doc,'beds_for_fresh',[]) 64 beds_for_pre = getattr(hall_doc,'beds_for_pre',[]) 65 beds_for_final = getattr(hall_doc,'beds_for_final',[]) 66 if set(blocks_for_female).intersection(set(blocks_for_male)): 59 67 return self.accommodation.acco_folder_view(beds_generated=beds_generated) 60 for block in hall_doc.blocks_for_female + hall_doc.blocks_for_male:68 for block in blocks_for_female + blocks_for_male: 61 69 sex = 'male' 62 if block in hall_doc.blocks_for_female:70 if block in blocks_for_female: 63 71 sex = 'female' 64 72 for floor in range(1,int(hall_doc.nr_of_floors)+1): … … 71 79 elif hall_doc.special_handling and not hall_doc.special_handling.startswith("no"): 72 80 bt = hall_doc.special_handling 73 elif bed in hall_doc.beds_for_fresh:81 elif bed in beds_for_fresh: 74 82 bt = 'fr' 75 elif bed in hall_doc.beds_for_pre:83 elif bed in beds_for_pre: 76 84 bt = 'pr' 77 elif bed in hall_doc.beds_for_final:85 elif bed in beds_for_final: 78 86 bt = 'fi' 79 87 if hall_doc.special_handling.startswith("no_"): … … 86 94 d['sort_id'] = getattr(hall_doc,'sort_id',0) 87 95 d['hall'] = hall.getId() 88 d['student'] = NOT_OCCUPIED89 try:90 #freelist.addRecord(bed = uid, bed_type = bt,hall = hall.getId())91 freelist.addRecord(**d)96 bed_record = bed_list.getRecordByKey(uid) 97 if bed_record is None: 98 d['student'] = NOT_OCCUPIED 99 bed_list.addRecord(**d) 92 100 count +=1 93 101 generated.append('"%(uid)s","%(bt)s"' % vars()) 94 except ValueError: 95 #freelist.modifyRecord(bed = uid, bed_type = bt,hall =hall.getId()) 96 #freelist.modifyRecord(**d) 102 elif bed_record.bed_type != bt: 103 bed_list.modifyRecord(**d) 104 modyfied.append('"%(uid)s","%(bt)s"' % vars()) 105 modyfied_count += 1 97 106 pass 98 107 hall_gen['count']= count 108 hall_gen['modyfied_count']= modyfied_count 99 109 beds_generated.append(hall_gen) 100 110 current = DateTime.DateTime().strftime("%d-%m-%y_%H_%M_%S") 101 111 open("%s/import/bedlist_%s.csv" % (i_home,current),"w+").write('\n'.join(generated)) 112 open("%s/import/bedlist_modyfied_%s.csv" % (i_home,current),"w+").write('\n'.join(modyfied)) 102 113 return self.accommodation.acco_folder_view(beds_generated=beds_generated) 103 104 ###) 114 ###) 105 115 106 116 security.declareProtected(ModifyPortalContent,"importReservedBeds")###( -
WAeUP_SRP/base/WAeUPTables.py
r3018 r3043 482 482 name = "portal_accommodation" 483 483 key = "bed" 484 not_occupied = NOT_OCCUPIED 484 485 def __init__(self,name=None): 485 486 if name == None: … … 487 488 WAeUPTable.__init__(self, name) 488 489 489 def searchAndReserveBed(self, student_id,bed_type): 490 def searchAndReserveBed(self, student_id,bed_type): ###( 490 491 #records = self.searchResults({'student' : student_id}) 491 492 #import pdb;pdb.set_trace() … … 504 505 s_logger.info('%s reserved bed %s' % (student_id,rec.bed)) 505 506 return 1,rec.bed 507 ###) 506 508 507 509 -
WAeUP_SRP/base/skins/waeup_accommodation/acco_folder_view.pt
r2890 r3043 22 22 <tr> 23 23 <th width="200px">Hall Name</th> 24 <th>New Beds Generated</th> 24 <th>Beds Generated</th> 25 <th>Beds Modyfied</th> 25 26 </tr> 26 27 <tr tal:repeat="hall beds_generated"> 27 28 <td tal:content="hall/name"></td> 28 29 <td tal:content="hall/count"></td> 30 <td tal:content="hall/modyfied_count"></td> 29 31 </tr> 30 32 </table> -
WAeUP_SRP/base/skins/waeup_accommodation/change_bed.py
r2454 r3043 44 44 return redirect("%s/%s/%s" % (students.absolute_url(),student,info['acco_id'])) 45 45 logger.info('Bed status %s of %s has changed to %s' % (allocated_bed.bed_type,student_id,status)) 46 beds.modifyRecord(bed=allocated_bed.bed,student= '')46 beds.modifyRecord(bed=allocated_bed.bed,student=beds.not_occupied) 47 47 logger.info('Bed %s released' % (allocated_bed.bed)) 48 48 code,bed = beds.searchAndReserveBed(student_id,status)
Note: See TracChangeset for help on using the changeset viewer.