Changeset 2845 for WAeUP_SRP/base
- Timestamp:
- 3 Dec 2007, 21:14:20 (17 years ago)
- Location:
- WAeUP_SRP/base
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
WAeUP_SRP/base/Accommodation.py
r2823 r2845 10 10 from Products.CPSDocument.CPSDocument import CPSDocument 11 11 from Products.CPSCore.CPSBase import CPSBaseBTreeFolder as BaseBTreeFolder 12 from Products.WAeUP_SRP.WAeUPTables import AccommodationTable 12 from Products.WAeUP_SRP.WAeUPTables import AccommodationTable,NOT_OCCUPIED 13 13 import logging 14 14 import csv,re,os … … 18 18 p_home = Globals.package_home(globals()) 19 19 i_home = Globals.INSTANCE_HOME 20 20 21 21 22 class AccoFolder(CPSDocument): ###( … … 47 48 for hall in halls: 48 49 #import pdb;pdb.set_trace() 49 h = hall.getContent()50 hall_doc = hall.getContent() 50 51 hall_gen = {} 51 52 hall_gen['name'] = hall.Title 52 53 count = 0 53 reserved = [(r.split('/')[0],int(r.split('/')[1])) for r in re.split(',|\.| ',h .reserved_rooms)54 reserved = [(r.split('/')[0],int(r.split('/')[1])) for r in re.split(',|\.| ',hall_doc.reserved_rooms) 54 55 if r] 55 #for block in range(1,int(h .nr_of_blocks)+1):56 # for block in 'ABCDEFGHIJ'[:int(h .nr_of_blocks)]:57 if set(h .blocks_for_female).intersection(set(h.blocks_for_male)):56 #for block in range(1,int(hall_doc.nr_of_blocks)+1): 57 # 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)): 58 59 return self.accommodation.acco_folder_view(beds_generated=beds_generated) 59 for block in h .blocks_for_female + h.blocks_for_male:60 for block in hall_doc.blocks_for_female + hall_doc.blocks_for_male: 60 61 sex = 'male' 61 if block in h .blocks_for_female:62 if block in hall_doc.blocks_for_female: 62 63 sex = 'female' 63 for floor in range(1,int(h .nr_of_floors)+1):64 for room in range(1,int(h .rooms_per_floor)+1):65 for bed in 'ABCDEFGH'[:int(h .beds_per_room)]:64 for floor in range(1,int(hall_doc.nr_of_floors)+1): 65 for room in range(1,int(hall_doc.rooms_per_floor)+1): 66 for bed in 'ABCDEFGH'[:int(hall_doc.beds_per_room)]: 66 67 room_nr = floor*100 + room 67 68 bt = 're' 68 69 if (block,room_nr) in reserved: 69 70 bt = "reserved" 70 elif h .special_handling and not h.special_handling.startswith("no"):71 bt = h .special_handling72 elif bed in h .beds_for_fresh:71 elif hall_doc.special_handling and not hall_doc.special_handling.startswith("no"): 72 bt = hall_doc.special_handling 73 elif bed in hall_doc.beds_for_fresh: 73 74 bt = 'fr' 74 elif bed in h .beds_for_pre:75 elif bed in hall_doc.beds_for_pre: 75 76 bt = 'pr' 76 elif bed in h .beds_for_final:77 elif bed in hall_doc.beds_for_final: 77 78 bt = 'fi' 78 if h .special_handling.startswith("no_"):79 bt += "_" + h .special_handling[3:]79 if hall_doc.special_handling.startswith("no_"): 80 bt += "_" + hall_doc.special_handling[3:] 80 81 bt = "%(sex)s_%(bt)s" % vars() 81 82 uid = '%s_%s_%d_%s' % (hall.getId(),block,room_nr,bed) 83 d = {} 84 d['bed'] = uid 85 d['bed_type'] = bt 86 d['sort_id'] = getattr(hall_doc,'sort_id') 87 d['hall'] = hall.getId() 88 d['student'] = NOT_OCCUPIED 82 89 try: 83 freelist.addRecord(bed = uid, bed_type = bt,hall = hall.getId()) 90 #freelist.addRecord(bed = uid, bed_type = bt,hall = hall.getId()) 91 freelist.addRecord(**d) 84 92 count +=1 85 93 generated.append('"%(uid)s","%(bt)s"' % vars()) 86 94 except ValueError: 87 95 #freelist.modifyRecord(bed = uid, bed_type = bt,hall =hall.getId()) 96 #freelist.modifyRecord(**d) 88 97 pass 89 98 hall_gen['count']= count … … 239 248 ###) 240 249 250 ###) 251 241 252 class AccoHall(CPSDocument): ###( 242 253 """ 243 WAeUP AccoHall containing Departments254 WAeUP AccoHall 244 255 """ 245 256 meta_type = 'AccoHall' -
WAeUP_SRP/base/WAeUPTables.py
r2781 r2845 41 41 ADDING_SHEDULED = "adding_sheduled" 42 42 OBJECT_CREATED = "object_created" 43 NOT_OCCUPIED = 'not_occupied' 43 44 44 45 from interfaces import IWAeUPTable … … 486 487 name = self.name 487 488 WAeUPTable.__init__(self, name) 488 489 489 490 def searchAndReserveBed(self, student_id,bed_type): 490 records = self.searchResults({'student' : student_id}) 491 #records = self.searchResults({'student' : student_id}) 492 import pdb;pdb.set_trace() 493 records = self.evalAdvancedQuery(Eq('student',student_id)) 491 494 if len(records) > 0: 492 495 return -1,"Student with Id %s already booked bed %s." % (student_id,records[0].bed) 493 496 494 records = [r for r in self.searchResults({'bed_type' : bed_type}) if not r.student] 495 #import pdb;pdb.set_trace() 497 #records = [r for r in self.searchResults({'bed_type' : bed_type}) if not r.student] 498 query = Eq('bed_type',bed_type) & Eq('student',NOT_OCCUPIED) 499 records = self.evalAdvancedQuery(query,sortSpecs=('sort_id','bed')) 496 500 if len(records) == 0: 497 501 return -2,"No bed available" -
WAeUP_SRP/base/skins/waeup_accommodation/acco_folder_view.pt
r2825 r2845 53 53 <strong tal:content="row/title" /></a> </td> 54 54 <td tal:content="row/id"> </td> 55 55 <td tal:content="row/sort_id"> </td> 56 56 <td> 57 <a tal:condition="row/is_editable"57 <a tal:condition="row/is_editable" 58 58 href="edit" tal:attributes="href string:/${row/url}/external_edit_form" 59 59 target="edit" -
WAeUP_SRP/base/skins/waeup_accommodation/getAccoFolderInfo.py
r1447 r2845 12 12 return Info about the Accommodation-Folder 13 13 """ 14 try: 15 from Products.zdb import set_trace 16 except: 17 def set_trace(): 18 pass 14 19 request = context.REQUEST 15 20 … … 23 28 items = [] 24 29 is_editable = mtool.checkPermission('Modify portal content', context) 25 is_editable = False 26 halls = context.portal_catalog(portal_type='AccoHall') 27 for f in halls: 30 #is_editable = False 31 #halls = context.portal_catalog(portal_type='AccoHall') 32 for id,hall in context.objectItems(): 33 hall_doc = hall.getContent() 28 34 row = {} 29 row['id'] = f.id 30 row['title'] = f.Title 31 row['url'] = "%s/%s" % (context.absolute_url(),f.id) 35 row['id'] = id 36 row['title'] = hall_doc.Title() 37 row['sort_id'] = getattr(hall_doc,'sort_id',0) 38 row['url'] = "%s/%s" % (context.absolute_url(),id) 32 39 #fo = f.getObject() 33 40 #row['is_editable'] = mtool.checkPermission('Modify portal content', fo) 34 41 row['is_editable'] = is_editable 35 42 items.append(row) 43 items.sort(cmp=lambda x,y: cmp( x['sort_id'],y['sort_id'])) 36 44 info['items'] = items 37 45 return info -
WAeUP_SRP/base/skins/waeup_accommodation/getAccoHallInfo.py
r1914 r2845 12 12 return Info about a Accommodation Hall 13 13 """ 14 try: 15 from Products.zdb import set_trace 16 except: 17 def set_trace(): 18 pass 19 20 from Products.AdvancedQuery import Eq, Between, Le,In 14 21 15 22 def cmp_bed(a,b): … … 23 30 path_info = request.get('PATH_INFO').split('/') 24 31 mtool = context.portal_membership 25 pa = context.portal_accommodation 32 portal_accommodation = context.portal_accommodation 33 aq_accommodation = portal_accommodation.evalAdvancedQuery 26 34 info = {} 27 35 #dep_id = request.get('PATH_TRANSLATED').split('/')[-2] … … 30 38 info['choosen_ids'] = request.get('ids',[]) 31 39 info['doc'] = context.getContent() 32 bed_types = p a.uniqueValuesFor('bed_type')40 bed_types = portal_accommodation.uniqueValuesFor('bed_type') 33 41 bt_list = [] 34 42 bt_names = context.getBedTypeNames() 35 res = p a.uniqueValuesFor('student')36 all_booked = [st for st in res if st ]43 res = portal_accommodation.uniqueValuesFor('student') 44 all_booked = [st for st in res if st and st != 'not_occupied'] 37 45 booked_list = [] 38 #from Products.zdb import set_trace;set_trace()39 46 for bt in bed_types: 40 total = len(p a(bed_type=bt,hall=context.getId()))47 total = len(portal_accommodation(bed_type=bt,hall=context.getId())) 41 48 if total <= 1: 42 49 continue 43 booked = p a.searchResults({'bed_type': bt,50 booked = portal_accommodation.searchResults({'bed_type': bt, 44 51 'student':all_booked, 45 52 'hall': context.getId()}) … … 49 56 }) 50 57 booked_list.extend(booked) 58 # query = ~Eq('student','not_occupied') 59 # beds = aq_accommodation(query,sortSpecs=('bed_type',)) 60 # bt_list = [] 61 # bt_names = context.getBedTypeNames() 62 # bt = 'xxx' 63 # for bed in beds: 64 # if bt != bed.bed_type: 65 # bt = bed.bed_type 66 # total = len(aq_accommodation(Eq('bed_type',bt))) 67 # bt_list.append({'name': bt_names[bt], 68 # 'total': total, 69 # 'reserved': len(booked), 70 # }) 71 51 72 info['bed_types'] = bt_list 52 73 res_list = []
Note: See TracChangeset for help on using the changeset viewer.