Changeset 13346
- Timestamp:
- 26 Oct 2015, 08:57:30 (9 years ago)
- Location:
- main/waeup.kofa/trunk
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/CHANGES.txt
r13344 r13346 4 4 1.3.4.dev0 (unreleased) 5 5 ======================= 6 7 * Remove `beds_reserved` attribute from hostels. Hostels do no longer 8 contain information about reserved bed spaces. 6 9 7 10 * Add methods and page to release expired bed allocations. -
main/waeup.kofa/trunk/src/waeup/kofa/hostels/browser.py
r13320 r13346 265 265 return 266 266 267 @action(_('Update all beds'), style='primary') 267 @action(_('Update all beds'), style='primary', 268 warning=_('Attention: The updater removes all reservation flags of existing beds.' 269 ' You really want to update?')) 268 270 def updateBeds(self, **data): 269 271 removed, added, modified, modified_beds = self.context.updateBeds() -
main/waeup.kofa/trunk/src/waeup/kofa/hostels/browser_templates/hostelmanagepage.pt
r13302 r13346 21 21 <tbody> 22 22 <tal:widgets content="structure provider:widgets" /> 23 <tr>24 <td class="fieldname" i18n:translate="" >25 Reserved Beds:26 </td>27 <td>28 <tal:repeat repeat="bed context/beds_reserved" >29 <span tal:replace='bed'>BED</span> 30 </tal:repeat>31 </td>32 </tr>33 23 </tbody> 34 24 </table> … … 79 69 </table> 80 70 <input type="checkbox" onClick="toggle(this, 'val_id')" /> 81 <span i18n:translate="">Select all</span>71 <span i18n:translate="">Select all</span> 82 72 <br /><br /> 83 73 <div tal:condition="view/availableActions"> -
main/waeup.kofa/trunk/src/waeup/kofa/hostels/browser_templates/hostelpage.pt
r9534 r13346 2 2 <tbody> 3 3 <tal:widgets content="structure provider:widgets" /> 4 <tr>5 <td class="fieldname" i18n:translate="" >6 Reserved Beds:7 </td>8 <td>9 <tal:repeat repeat="bed context/beds_reserved" >10 <span tal:replace='bed'>BED</span> 11 </tal:repeat>12 </td>13 </tr>14 4 </tbody> 15 5 </table> -
main/waeup.kofa/trunk/src/waeup/kofa/hostels/hostel.py
r13318 r13346 90 90 beds_for_final = getattr(self,'beds_for_final',[]) 91 91 beds_for_all = getattr(self,'beds_for_all',[]) 92 beds_reserved = getattr(self,'beds_reserved',[])93 92 all_blocks = blocks_for_female + blocks_for_male 94 93 all_beds = (beds_for_pre + beds_for_fresh + … … 103 102 room_nr = floor*100 + room 104 103 bt = 'all' 105 if '%s_%s_%s' % (block,room_nr,bed) in beds_reserved: 106 bt = "reserved" 107 elif bed in beds_for_fresh: 104 if bed in beds_for_fresh: 108 105 bt = 'fr' 109 106 elif bed in beds_for_pre: … … 218 215 bt = 're' 219 216 bt = u'%s_%s_%s' % (sh, sex, bt) 220 221 # Comment of Martijn:222 # If you have a non-Persistent subobject (like a list) and223 # you change it, you need to manually flag the persistence224 # machinery on the object that its subobject changed, with225 # _p_changed. This is only necessary if some of the226 # objects are not sublclasses of Persistent. For common227 # built-in collections in Python such as list and228 # dictionary there are replacements (PersistentList,229 # PersistentMapping), and more advanced building blocks230 # for indexes (BTrees), that don't have this issue.231 #hostel._p_changed = True232 233 # Henrik: Unfortunately, this doesn't work in our case.234 # After restarting the portal,235 # added or removed list items are gone. The only way to ensure236 # persistance is to reassign the list attribute.237 br = hostel.beds_reserved238 br.remove(bed_string)239 hostel.beds_reserved = br240 217 message = _(u'unreserved') 241 218 else: 242 219 bt = u'%s_%s_reserved' % (sh, sex) 243 # See comment above244 br = hostel.beds_reserved245 br.append(bed_string)246 hostel.beds_reserved = br247 220 message = _(u'reserved') 248 221 self.bed_type = bt -
main/waeup.kofa/trunk/src/waeup/kofa/hostels/interfaces.py
r13316 r13346 122 122 ) 123 123 124 beds_reserved = schema.List(125 title = _(u'Reserved Beds'),126 value_type = schema.TextLine(127 default = u'',128 required = False,129 ),130 required = True,131 readonly = False,132 default = [],133 )134 135 124 blocks_for_female = schema.List( 136 125 title = _(u'Blocks for Female Students'), … … 138 127 vocabulary = blocks 139 128 ), 129 default = [], 140 130 ) 141 131 … … 145 135 vocabulary = blocks 146 136 ), 137 default = [], 147 138 ) 148 139 … … 152 143 vocabulary = bed_letters 153 144 ), 145 default = [], 154 146 ) 155 147 … … 159 151 vocabulary = bed_letters 160 152 ), 153 default = [], 161 154 ) 162 155 … … 166 159 vocabulary = bed_letters 167 160 ), 161 default = [], 168 162 ) 169 163 … … 173 167 vocabulary = bed_letters 174 168 ), 169 default = [], 175 170 ) 176 171 … … 180 175 vocabulary = bed_letters 181 176 ), 177 default = [], 182 178 ) 183 179 -
main/waeup.kofa/trunk/src/waeup/kofa/hostels/sample_hostel_data.csv
r9202 r13346 1 beds_for_all,beds_for_final,beds_for_fresh,beds_for_pre,beds_for_returning,b eds_reserved,blocks_for_female,blocks_for_male,floors_per_block,hostel_id,hostel_name,rooms_per_floor,sort_id,special_handling2 [],"['A', 'B']","['E', 'F']",['G'],"['C', 'D']",[ ],['A'],[],1,block-a-upper-hostel,Block A Upper Hostel,32,20,regular3 [],"['A', 'B']","['E', 'F']",['G'],"['C', 'D']",[ ],['B'],[],1,block-b-upper-hostel,Block B Upper Hostel,32,30,regular4 [],"['A', 'B']","['E', 'F']",['G'],"['C', 'D']",[ ],['C'],[],1,block-c-upper-hostel,Block C Upper Hostel,32,40,regular5 [],"['A', 'B']","['E', 'F']",['G'],"['C', 'D']",[ ],['D'],[],1,block-d-upper-hostel,Block D Upper Hostel,32,50,regular6 [],"['A', 'B']","['E', 'F']",['G'],"['C', 'D']",[ ],['E'],[],1,block-e-down-hostel,Block E Down Hostel,32,60,regular7 [],"['A', 'B']","['E', 'F']",['G'],"['C', 'D']",[ ],['F'],[],1,block-f-down-hostel,Block F Down Hostel,32,70,regular8 [],"['A', 'B']","['E', 'F']",['G'],"['C', 'D']",[ ],['G'],[],1,block-g-down-hostel,Block G Down Hostel,32,80,regular9 [],"['A', 'B']","['D', 'E']",['F'],['C'],[], [],"['A', 'B']",1,hall-a,Hall A,44,90,regular10 [],"['A', 'B']","['D', 'E']",['F'],['C'],[], [],"['C', 'D']",1,hall-b,Hall B,44,100,regular11 [],[],[],[],[],[],[ ],['A'],1,stores-32,Stores 32,16,10,regular1 beds_for_all,beds_for_final,beds_for_fresh,beds_for_pre,beds_for_returning,blocks_for_female,blocks_for_male,floors_per_block,hostel_id,hostel_name,rooms_per_floor,sort_id,special_handling 2 [],"['A', 'B']","['E', 'F']",['G'],"['C', 'D']",['A'],[],1,block-a-upper-hostel,Block A Upper Hostel,32,20,regular 3 [],"['A', 'B']","['E', 'F']",['G'],"['C', 'D']",['B'],[],1,block-b-upper-hostel,Block B Upper Hostel,32,30,regular 4 [],"['A', 'B']","['E', 'F']",['G'],"['C', 'D']",['C'],[],1,block-c-upper-hostel,Block C Upper Hostel,32,40,regular 5 [],"['A', 'B']","['E', 'F']",['G'],"['C', 'D']",['D'],[],1,block-d-upper-hostel,Block D Upper Hostel,32,50,regular 6 [],"['A', 'B']","['E', 'F']",['G'],"['C', 'D']",['E'],[],1,block-e-down-hostel,Block E Down Hostel,32,60,regular 7 [],"['A', 'B']","['E', 'F']",['G'],"['C', 'D']",['F'],[],1,block-f-down-hostel,Block F Down Hostel,32,70,regular 8 [],"['A', 'B']","['E', 'F']",['G'],"['C', 'D']",['G'],[],1,block-g-down-hostel,Block G Down Hostel,32,80,regular 9 [],"['A', 'B']","['D', 'E']",['F'],['C'],[],"['A', 'B']",1,hall-a,Hall A,44,90,regular 10 [],"['A', 'B']","['D', 'E']",['F'],['C'],[],"['C', 'D']",1,hall-b,Hall B,44,100,regular 11 [],[],[],[],[],[],['A'],1,stores-32,Stores 32,16,10,regular -
main/waeup.kofa/trunk/src/waeup/kofa/hostels/tests.py
r13319 r13346 311 311 self.assertEqual(self.app['hostels']['hall-1'][ 312 312 'hall-1_A_101_D'].bed_type, 'regular_female_reserved') 313 self.assertTrue('A_101_A ' in self.browser.contents)314 313 # The catalog has been updated. 315 314 results = cat.searchResults( … … 340 339 bed_type=('regular_female_all', 'regular_female_all')) 341 340 results = [(x.bed_id, x.bed_type) for x in results] 341 # The reservation of hall-1_A_101_D has been cancelled. 342 342 self.assertEqual(results, 343 [(u'hall-1_B_101_D', u'regular_female_all'),]) 344 # Unreserve beds. 345 ctrl = self.browser.getControl(name='val_id') 346 ctrl.getControl(value='hall-1_A_101_A').selected = True 347 ctrl.getControl(value='hall-1_A_101_B').selected = True 348 ctrl.getControl(value='hall-1_A_101_C').selected = True 349 ctrl.getControl(value='hall-1_A_101_D').selected = True 350 self.browser.getControl("Switch reservation", index=0).click() 351 assert self.app['hostels']['hall-1'][ 352 'hall-1_A_101_D'].bed_type == 'regular_female_all' 353 self.assertFalse(expected in self.browser.contents) 343 [(u'hall-1_A_101_D', u'regular_female_all'), 344 (u'hall-1_B_101_D', u'regular_female_all')]) 354 345 # Release bed which has previously been booked. 355 346 bedticket = BedTicket() … … 508 499 result, 509 500 'beds_for_all,beds_for_final,beds_for_fresh,beds_for_pre,' 510 'beds_for_returning,b eds_reserved,blocks_for_female,'501 'beds_for_returning,blocks_for_female,' 511 502 'blocks_for_male,floors_per_block,hostel_id,hostel_name,maint_fee,' 512 'rooms_per_floor,sort_id,special_handling\r\n ,,,,,[],,,1,'513 ' hall-x,Hall 1,0.0,2,10,regular\r\n'503 'rooms_per_floor,sort_id,special_handling\r\n[],[],[],[],[],[],[],' 504 '1,hall-x,Hall 1,0.0,2,10,regular\r\n' 514 505 ) 515 506 return … … 554 545 "updated: " 555 546 "beds_for_pre=['G'], floors_per_block=1, " 547 "special_handling=regular, " 556 548 "beds_for_final=['A', 'B'], rooms_per_floor=32, " 557 549 "hostel_id=block-a-upper-hostel, " … … 562 554 shutil.rmtree(os.path.dirname(fin_file)) 563 555 shutil.rmtree(self.workdir) 556 # The manage page can be opened. 557 self.browser.addHeader('Authorization', 'Basic mgr:mgrpw') 558 self.browser.open(self.container_path + '/block-a-upper-hostel') 559 self.browser.getLink("Manage").click() 560 self.assertEqual(self.browser.headers['Status'], '200 Ok') 564 561 return 565 562 … … 582 579 "updated: " 583 580 "beds_for_pre=['G'], floors_per_block=1, " 581 "special_handling=regular, " 584 582 "beds_for_final=['A', 'B'], rooms_per_floor=32, " 585 583 "hostel_id=block-a-upper-hostel, "
Note: See TracChangeset for help on using the changeset viewer.