Changeset 7003 for main/waeup.sirp/trunk
- Timestamp:
- 4 Nov 2011, 21:26:33 (13 years ago)
- Location:
- main/waeup.sirp/trunk/src/waeup/sirp
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/hostels/hostel.py
r6998 r7003 18 18 """ 19 19 import grok 20 from zope.event import notify 20 21 from datetime import datetime 21 22 from grok import index … … 130 131 if self.owner == NOT_OCCUPIED: 131 132 self.owner = student_id 133 notify(grok.ObjectModifiedEvent(self)) 132 134 return None 133 135 else: … … 135 137 136 138 def switchReservation(self): 137 """Reserves a bedor unreserve bed respectively.139 """Reserves or unreserve bed respectively. 138 140 """ 139 141 sh, sex, bt = self.bed_type.split('_') -
main/waeup.sirp/trunk/src/waeup/sirp/hostels/tests.py
r6988 r7003 19 19 import shutil 20 20 import tempfile 21 import grok 22 from zope.event import notify 23 21 24 from zope.interface.verify import verifyClass, verifyObject 22 25 from zope.component.hooks import setSite, clearSite … … 130 133 # We can find a certain bed 131 134 cat = queryUtility(ICatalog, name='beds_catalog') 132 results = cat.searchResults(bed_type=('abc', 'abc')) 135 results = cat.searchResults(bed_type=(u'abc', u'abc')) 136 results = [x for x in results] # Turn results generator into list 137 assert len(results) == 1 138 assert results[0] is self.app['hostels']['hall-x']['xyz'] 139 140 def test_search_by_owner(self): 141 # We can find a certain bed 142 myobj = self.app['hostels']['hall-x']['xyz'] 143 myobj.owner = u'abc' 144 notify(grok.ObjectModifiedEvent(myobj)) 145 cat = queryUtility(ICatalog, name='beds_catalog') 146 results = cat.searchResults(owner=(u'abc', u'abc')) 133 147 results = [x for x in results] # Turn results generator into list 134 148 assert len(results) == 1 -
main/waeup.sirp/trunk/src/waeup/sirp/students/browser.py
r6997 r7003 1108 1108 self.flash('Activation code is invalid.') 1109 1109 return 1110 # Search a bed and exit if no bed is found 1110 # Search a bed and exit if no bed is found or if the student 1111 # has already booked a bed 1111 1112 cat = queryUtility(ICatalog, name='beds_catalog', default=None) 1112 1113 entries = cat.searchResults( … … 1117 1118 self.flash('There is no free bed in your category %s.' 1118 1119 % acc_details['bt']) 1120 return 1121 entries = cat.searchResults( 1122 owner=(student.student_id,student.student_id)) 1123 if len(entries): 1124 bed = [entry for entry in entries][0] 1125 self.flash('You already booked bed %s.' 1126 % bed.bed_id) 1119 1127 return 1120 1128 # Mark pin as used (this also fires a pin related transition)
Note: See TracChangeset for help on using the changeset viewer.