Changeset 7060 for main/waeup.sirp/trunk
- Timestamp:
- 9 Nov 2011, 13:34:17 (13 years ago)
- Location:
- main/waeup.sirp/trunk/src/waeup/sirp/students
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/students/browser.py
r7059 r7060 1238 1238 if str(grok.getSite()[ 1239 1239 'configuration'].accommodation_session) in self.context.keys(): 1240 self.flash('You already booked a bed space for thecurrent accommodation session.')1240 self.flash('You already booked a bed space in current accommodation session.') 1241 1241 self.redirect(self.url(self.context)) 1242 1242 return … … 1250 1250 self.flash('Activation code is invalid.') 1251 1251 return 1252 # Search a bed and exit if no bed is found or if the student 1253 # has already booked a bed 1252 # Search and book bed 1254 1253 cat = queryUtility(ICatalog, name='beds_catalog', default=None) 1255 1254 entries = cat.searchResults( 1256 bed_type=(acc_details['bt'],acc_details['bt']))1257 available_beds = [1258 entry for entry in entries if entry.owner == NOT_OCCUPIED]1259 if not available_beds:1260 self.flash('There is no free bed in your category %s.'1261 % acc_details['bt'])1262 return1263 entries = cat.searchResults(1264 1255 owner=(student.student_id,student.student_id)) 1265 # Cannot happen but anyway ...1266 1256 if len(entries): 1257 # If bed space has bee manually allocated use this bed 1267 1258 bed = [entry for entry in entries][0] 1268 self.flash('You already booked bed %s.' 1269 % bed.bed_id) 1270 return 1259 else: 1260 # else search for other available beds 1261 entries = cat.searchResults( 1262 bed_type=(acc_details['bt'],acc_details['bt'])) 1263 available_beds = [ 1264 entry for entry in entries if entry.owner == NOT_OCCUPIED] 1265 if available_beds: 1266 bed = self.selectBed(available_beds) 1267 bed.bookBed(student.student_id) 1268 else: 1269 self.flash('There is no free bed in your category %s.' 1270 % acc_details['bt']) 1271 return 1271 1272 # Mark pin as used (this also fires a pin related transition) 1272 1273 if code.state == USED: … … 1281 1282 self.flash('You are not the owner of this access code.') 1282 1283 return 1283 # Create bed ticket and book bed1284 # Create bed ticket 1284 1285 bedticket = createObject(u'waeup.BedTicket') 1285 1286 bedticket.booking_code = pin 1286 1287 bedticket.booking_session = acc_details['booking_session'] 1287 1288 bedticket.bed_type = acc_details['bt'] 1288 bed = self.selectBed(available_beds)1289 bed.bookBed(student.student_id)1290 1289 bedticket.bed = bed 1291 1290 hall_title = bed.__parent__.hostel_name -
main/waeup.sirp/trunk/src/waeup/sirp/students/tests/test_browser.py
r7057 r7060 1004 1004 pin = self.app['accesscodes']['HOS-0'].keys()[0] 1005 1005 ac = self.app['accesscodes']['HOS-0'][pin] 1006 ac.owner = self.student_id1006 ac.owner = u'Anybody' 1007 1007 parts = pin.split('-')[1:] 1008 1008 sfeseries, sfenumber = parts … … 1017 1017 self.assertMatches('...Activation Code:...', 1018 1018 self.browser.contents) 1019 self.browser.getControl(name="ac_series").value = u'nonsense' 1020 self.browser.getControl(name="ac_number").value = sfenumber 1021 self.browser.getControl("Create bed ticket").click() 1022 self.assertMatches('...Activation code is invalid...', 1023 self.browser.contents) 1024 self.browser.getControl(name="ac_series").value = sfeseries 1025 self.browser.getControl(name="ac_number").value = sfenumber 1026 self.browser.getControl("Create bed ticket").click() 1027 self.assertMatches('...You are not the owner of this access code...', 1028 self.browser.contents) 1029 ac.owner = self.student_id 1019 1030 self.browser.getControl(name="ac_series").value = sfeseries 1020 1031 self.browser.getControl(name="ac_number").value = sfenumber
Note: See TracChangeset for help on using the changeset viewer.