- Timestamp:
- 1 Nov 2011, 08:12:36 (13 years ago)
- Location:
- main/waeup.sirp/trunk/src/waeup/sirp/hostels
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/hostels/browser.py
r6975 r6978 223 223 @grok.action('Update all beds') 224 224 def updateBeds(self, **data): 225 added, modified = self.context.updateBeds() 226 self.flash('%d added, %d modified' % (added, modified)) 225 removed, added, modified = self.context.updateBeds() 226 self.flash('%d empty beds removed, %d beds added, %d occupied beds modified' % ( 227 removed, added, modified)) 227 228 self.redirect(self.url(self.context, '@@manage')+'#tab-2') 228 229 return … … 250 251 return 251 252 if len(switched): 252 #import pdb; pdb.set_trace() 253 self.flash('Successfully switched: %s' % ', '.join(switched)) 253 self.flash('Successfully switched beds: %s' % ', '.join(switched)) 254 254 self.redirect(self.url(self.context, '@@manage')+'#tab-2') 255 255 return -
main/waeup.sirp/trunk/src/waeup/sirp/hostels/hostel.py
r6976 r6978 44 44 return 45 45 46 # not yet tested nor used47 46 def updateBeds(self): 48 47 """Fill hostel with beds or update beds. … … 50 49 added_counter = 0 51 50 modified_counter = 0 51 removed_counter = 0 52 53 # Remove all empty beds. Occupied beds remain in hostel! 54 keys = list(self.keys()) # create list copy 55 for key in keys: 56 if self[key].owner == NOT_OCCUPIED: 57 del self[key] 58 self._p_changed = True 59 removed_counter += 1 60 52 61 blocks_for_female = getattr(self,'blocks_for_female',[]) 53 62 blocks_for_male = getattr(self,'blocks_for_male',[]) … … 86 95 if bed.bed_type != bt: 87 96 bed.bed_type = bt 88 #modified.append('"%(uid)s","%(bt)s","%(bed.owner)s"' % vars())89 97 modified_counter += 1 90 98 else: … … 95 103 bed.owner = NOT_OCCUPIED 96 104 self.addBed(bed) 97 #generated.append('"%(uid)s","%(bt)s"' % vars())98 105 added_counter +=1 99 return added_counter, modified_counter106 return removed_counter, added_counter, modified_counter 100 107 101 108 Hostel = attrs_to_fields(Hostel)
Note: See TracChangeset for help on using the changeset viewer.