Changeset 13484 for main/waeup.kofa/trunk/src/waeup/kofa
- Timestamp:
- 19 Nov 2015, 11:34:48 (9 years ago)
- Location:
- main/waeup.kofa/trunk/src/waeup/kofa/hostels
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/hostels/browser.py
r13476 r13484 115 115 text = _('Manage accommodation section') 116 116 117 class HostelsStatisticsActionButton(ManageActionButton): 118 grok.order(2) 119 grok.context(IHostelsContainer) 120 grok.view(HostelsContainerPage) 121 grok.require('waeup.manageHostels') 122 icon = 'actionicon_statistics.png' 123 text = _('Bed statistics') 124 target = 'statistics' 125 117 126 class HostelsContainerManagePage(KofaEditFormPage): 118 127 """The manage page for hostel containers. … … 196 205 def render(self): 197 206 return 207 208 class HostelsStatisticsPage(KofaDisplayFormPage): 209 """Some statistics about beds in hostels. 210 """ 211 grok.context(IHostelsContainer) 212 grok.name('statistics') 213 grok.require('waeup.manageHostels') 214 grok.template('containerstatistics') 215 label = _('Bed Statistics') 198 216 199 217 class HostelAddFormPage(KofaAddFormPage): -
main/waeup.kofa/trunk/src/waeup/kofa/hostels/tests.py
r13483 r13484 238 238 stats = utils.getBedStatistics() 239 239 self.assertEqual(stats, 240 {'regular_male_fr': (1, 1), 241 'regular_female_fi': (0, 0), 242 'regular_male_re': (0, 0), 243 'regular_female_fr': (0, 0), 244 'regular_female_all': (0, 0), 245 'regular_female_re': (0, 0), 246 'regular_male_fi': (0, 0), 247 'regular_male_all': (0, 0)} 240 {'regular_male_fr': (0, 1, 1), 241 'regular_female_fi': (0, 0, 0), 242 'regular_male_re': (0, 0, 0), 243 'regular_female_fr': (0, 0, 0), 244 'regular_female_all': (0, 0, 0), 245 'regular_female_re': (0, 0, 0), 246 'regular_female_reserved': (0, 0, 0), 247 'regular_male_reserved': (0, 0, 0), 248 'regular_male_fi': (0, 0, 0), 249 'regular_male_all': (0, 0, 0)} 248 250 ) 249 251 self.app[ … … 253 255 stats = utils.getBedStatistics() 254 256 self.assertEqual(stats, 255 {'regular_male_fr': (0, 1), 256 'regular_female_fi': (0, 0), 257 'regular_male_re': (0, 0), 258 'regular_female_fr': (0, 0), 259 'regular_female_all': (0, 0), 260 'regular_female_re': (0, 0), 261 'regular_male_fi': (0, 0), 262 'regular_male_all': (0, 0)} 257 {'regular_male_fr': (1, 0, 1), 258 'regular_female_fi': (0, 0, 0), 259 'regular_male_re': (0, 0, 0), 260 'regular_female_fr': (0, 0, 0), 261 'regular_female_all': (0, 0, 0), 262 'regular_female_re': (0, 0, 0), 263 'regular_female_reserved': (0, 0, 0), 264 'regular_male_reserved': (0, 0, 0), 265 'regular_male_fi': (0, 0, 0), 266 'regular_male_all': (0, 0, 0)} 263 267 ) 264 268 … … 478 482 self.assertTrue('2 of 10' in self.browser.contents) 479 483 bedticket.bed = self.app['hostels']['hall-1']['hall-1_A_101_A'] 484 # Managers can open the bed statistics page 485 self.browser.getLink("Bed statistics").click() 486 self.assertTrue('Bed Statistics</h1>' in self.browser.contents) 480 487 # Remove entire hostel. 481 488 self.browser.open(self.manage_container_path) -
main/waeup.kofa/trunk/src/waeup/kofa/hostels/utils.py
r13483 r13484 39 39 'regular_female_fi', 40 40 'regular_female_all', 41 'regular_female_reserved', 41 42 'regular_male_fr', 42 43 'regular_male_re', 43 44 'regular_male_fi', 44 'regular_male_all',) 45 'regular_male_all', 46 'regular_male_reserved',) 45 47 for bed_type in bed_types: 46 no= cat.searchResults(48 free = cat.searchResults( 47 49 bed_type=(bed_type, bed_type), 48 50 owner=(NOT_OCCUPIED, NOT_OCCUPIED)) 49 51 all = cat.searchResults( 50 52 bed_type=(bed_type, bed_type)) 51 stats[bed_type] = (len(no), len(all)) 53 free = len(free) 54 total = len(all) 55 occ = total - free 56 stats[bed_type] = (occ, free, total) 52 57 return stats
Note: See TracChangeset for help on using the changeset viewer.