Changeset 6997 for main/waeup.sirp
- Timestamp:
- 4 Nov 2011, 17:32:02 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/students/browser.py
r6996 r6997 53 53 from waeup.sirp.browser.resources import toggleall 54 54 from waeup.sirp.authentication import get_principal_role_manager 55 from waeup.sirp.hostels.hostel import NOT_OCCUPIED 55 56 56 57 def write_log_message(view, message): … … 1107 1108 self.flash('Activation code is invalid.') 1108 1109 return 1110 # Search a bed and exit if no bed is found 1111 cat = queryUtility(ICatalog, name='beds_catalog', default=None) 1112 entries = cat.searchResults( 1113 bed_type=(acc_details['bt'],acc_details['bt'])) 1114 available_beds = [ 1115 entry for entry in entries if entry.owner == NOT_OCCUPIED] 1116 if not available_beds: 1117 self.flash('There is no free bed in your category %s.' 1118 % acc_details['bt']) 1119 return 1109 1120 # Mark pin as used (this also fires a pin related transition) 1110 1121 if code.state == USED: … … 1119 1130 self.flash('You are not the owner of this access code.') 1120 1131 return 1132 # Create bed ticket and book bed 1121 1133 bedticket = createObject(u'waeup.BedTicket') 1122 1134 bedticket.booking_code = pin 1123 1135 bedticket.booking_session = acc_details['booking_session'] 1124 1136 bedticket.bed_type = acc_details['bt'] 1125 # Search and book bed 1126 cat = queryUtility(ICatalog, name='beds_catalog', default=None) 1127 entries = cat.searchResults( 1128 bed_type=(bedticket.bed_type,bedticket.bed_type)) 1129 bed = [entry for entry in entries if entry.owner == NOT_OCCUPIED][0] # first bed found 1137 bed = available_beds[0] # first bed found 1130 1138 bed.bookBed(student.student_id) 1131 1139 bedticket.bed = bed # maybe wo don't need the bed object itself
Note: See TracChangeset for help on using the changeset viewer.