Changeset 7070
- Timestamp:
- 11 Nov 2011, 07:44:46 (13 years ago)
- Location:
- main/waeup.sirp/trunk/src/waeup/sirp/hostels
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/hostels/browser.py
r7068 r7070 289 289 for bed_id in child_id: 290 290 message = self.context[bed_id].releaseBed() 291 released.append('%s (%s)' % (bed_id,message)) 291 if message: 292 released.append('%s (%s)' % (bed_id,message)) 292 293 if len(released): 293 294 message = ', '.join(released) 294 295 self.flash('Successfully released beds: %s' % message) 295 296 write_log_message(self, 'released: %s' % message) 297 self.redirect(self.url(self.context, '@@manage')+'#tab-2') 298 else: 299 self.flash('No allocated bed selected.') 296 300 self.redirect(self.url(self.context, '@@manage')+'#tab-2') 297 301 return -
main/waeup.sirp/trunk/src/waeup/sirp/hostels/container.py
r6959 r7070 55 55 """ 56 56 user = get_current_principal() 57 if user is None: 58 user = 'system' 59 else: 60 user = user.id 57 user = user.id 61 58 self.logger.info('%s - %s - %s - %s' % ( 62 59 user, ob_class, target, comment)) -
main/waeup.sirp/trunk/src/waeup/sirp/hostels/hostel.py
r7068 r7070 178 178 def releaseBed(self): 179 179 if self.owner == NOT_OCCUPIED: 180 return u'not occupied'180 return 181 181 else: 182 182 old_owner = self.owner … … 186 186 'configuration'].accommodation_session 187 187 try: 188 #import pdb; pdb.set_trace()189 188 bedticket = grok.getSite()['students'][old_owner][ 190 189 'accommodation'][str(accommodation_session)] -
main/waeup.sirp/trunk/src/waeup/sirp/hostels/tests.py
r7068 r7070 283 283 self.assertMatches(bedticket.bed_coordinates, 284 284 u' -- booking cancelled on <YYYY-MM-DD hh:mm:ss> --') 285 # If we release a free be, nothing will happen 286 ctrl = self.browser.getControl(name='val_id') 287 ctrl.getControl(value='hall-1_A_101_D').selected = True 288 self.browser.getControl("Release selected beds", index=0).click() 289 self.assertMatches( 290 '...No allocated bed selected...', self.browser.contents) 285 291 # Managers can manually allocate studenst after cancellation 286 292 self.browser.open(self.container_path + '/hall-1/hall-1_A_101_A') … … 288 294 self.browser.getControl("Save").click() 289 295 self.assertMatches("...Form has been saved...", self.browser.contents) 296 # If we open the same form again, we will be redirected to hostel 297 # manage page. Beds must be released first before they can be 298 # allocated to other students. 299 self.browser.open(self.container_path + '/hall-1/hall-1_A_101_A') 300 self.assertEqual(self.browser.url, 301 self.container_path + '/hall-1/@@manage#tab-2') 302 # Updating the beds again will not affect the allocation and also 303 # the bed numbering remains the same 304 old_number = self.app['hostels']['hall-1']['hall-1_A_101_A'].bed_number 305 old_owner = self.app['hostels']['hall-1']['hall-1_A_101_A'].owner 306 self.browser.getControl("Update all beds").click() 307 # 7 beds have been removed and re-added, 1 bed remains untouched 308 expected = '...7 empty beds removed, 7 beds added, 0 occupied beds modified...' 309 self.assertMatches(expected,self.browser.contents) 310 new_number = self.app['hostels']['hall-1']['hall-1_A_101_A'].bed_number 311 new_owner = self.app['hostels']['hall-1']['hall-1_A_101_A'].owner 312 self.assertEqual(new_number, old_number) 313 self.assertEqual(new_owner, old_owner) 314 # If we change the bed type of an allocated bed, the modification will 315 # be indicated 316 hall.blocks_for_female = ['B'] 317 hall.blocks_for_male = ['A'] 318 self.browser.getControl("Update all beds").click() 319 expected = '...7 empty beds removed, 7 beds added, ' + \ 320 '1 occupied beds modified (hall-1_A_101_A )...' 321 self.assertMatches(expected,self.browser.contents) 322 new_number = self.app['hostels']['hall-1']['hall-1_A_101_A'].bed_number 323 # Also the number of the bed has changed. 324 self.assertFalse(new_number == old_number) 290 325 # Remove entire hostel 291 326 self.browser.open(self.manage_container_path) -
main/waeup.sirp/trunk/src/waeup/sirp/hostels/vocabularies.py
r7068 r7070 19 19 students = catalog.searchResults(current_session=( 20 20 accommodation_session,accommodation_session)) 21 try: 22 existing_students = [ 23 context.__parent__[key].owner 24 for key in context.__parent__.keys()] 25 except AttributeError: 26 return {NOT_OCCUPIED:NOT_OCCUPIED} 21 existing_students = [ 22 context.__parent__[key].owner 23 for key in context.__parent__.keys()] 27 24 students = [student for student in students 28 25 if not student.student_id in existing_students]
Note: See TracChangeset for help on using the changeset viewer.