Changeset 9196 for main/waeup.kofa/trunk/src/waeup/kofa
- Timestamp:
- 18 Sep 2012, 10:42:09 (12 years ago)
- Location:
- main/waeup.kofa/trunk/src/waeup/kofa/hostels
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/hostels/browser_templates/containerpage.pt
r8685 r9196 21 21 <th i18n:translate="">Id</th> 22 22 <th i18n:translate="">Name</th> 23 <th i18n:translate="">Booked Beds</th> 23 24 </tr> 24 25 </thead> 25 26 <tbody> 26 <tr tal:repeat="value context/values"> 27 <td> <a tal:attributes="href value/__name__"> 28 <span tal:content="value/hostel_id">ID</span></a></td> 29 <td tal:content="value/hostel_name">NAME</td> 30 </tr> 27 <tal:tbody repeat="value context/values"> 28 <tr tal:define = "stats value/bed_statistics"> 29 <td> <a tal:attributes="href value/__name__"> 30 <span tal:content="value/hostel_id">ID</span></a></td> 31 <td tal:content="value/hostel_name">NAME</td> 32 <td> 33 <span tal:replace="stats/booked">10</span> of <span tal:replace="stats/total">100</span> 34 </td> 35 </tr> 36 </tal:tbody> 31 37 </tbody> 32 38 </table> -
main/waeup.kofa/trunk/src/waeup/kofa/hostels/hostel.py
r8685 r9196 40 40 target = self.__name__ 41 41 return grok.getSite()['hostels'].logger_info(ob_class,target,comment) 42 43 @property 44 def bed_statistics(self): 45 total = len(self.keys()) 46 booked = 0 47 for value in self.values(): 48 if value.owner != NOT_OCCUPIED: 49 booked += 1 50 return {'booked':booked, 'total':total} 51 52 def clearHostel(self): 53 """Remove all beds. 54 55 This methods is pretty fast and optimized. Use it instead of 56 removing all items manually yourself. 57 """ 58 # This internal function is implemented in C and thus much 59 # faster as we could do it in pure Python. 60 self._SampleContainer__data.clear() 61 # The length attribute is 'lazy'. See `zope.container` for details. 62 # This way we make sure, the next time len() is called, it returns 63 # the real value and not a cached one. 64 del self.__dict__['_BTreeContainer__len'] 42 65 43 66 def addBed(self, bed): -
main/waeup.kofa/trunk/src/waeup/kofa/hostels/interfaces.py
r9146 r9196 17 17 ## 18 18 from datetime import datetime 19 from zope.interface import invariant, Invalid 19 from zope.interface import invariant, Invalid, Attribute 20 20 from zope import schema 21 21 from waeup.kofa.interfaces import ( … … 63 63 """ 64 64 65 bed_statistics = Attribute('Number of booked and total beds') 66 65 67 def loggerInfo(ob_class, comment): 66 68 """Adds an INFO message to the log file 69 """ 70 71 def clearHostel(): 72 """Remove all beds. 67 73 """ 68 74 -
main/waeup.kofa/trunk/src/waeup/kofa/hostels/tests.py
r8686 r9196 300 300 self.assertMatches( 301 301 '...No allocated bed selected...', self.browser.contents) 302 # Managers can manually allocate studen stafter cancellation302 # Managers can manually allocate students after cancellation 303 303 self.browser.open(self.container_path + '/hall-1/hall-1_A_101_A') 304 304 self.browser.getControl(name="form.owner").value = [self.student_id] … … 334 334 # Also the number of the bed has changed. 335 335 self.assertFalse(new_number == old_number) 336 # The number of occupied bed are displayed on container page. 337 self.browser.open(self.container_path) 338 self.assertTrue('1 of 8' in self.browser.contents) 336 339 # Remove entire hostel 337 340 self.browser.open(self.manage_container_path)
Note: See TracChangeset for help on using the changeset viewer.