Changeset 13457 for main/waeup.kofa/trunk/src/waeup/kofa/students/utils.py
- Timestamp:
- 16 Nov 2015, 09:05:30 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/students/utils.py
r13304 r13457 627 627 return 628 628 629 def selectBed(self, available_beds): 630 """Select a bed from a list of available beds. 631 In the base configuration we select the first bed found, 632 but can also randomize the selection if we like. 633 """ 634 return available_beds[0] 629 def selectBed(self, available_beds, desired_hostel=None): 630 """Select a bed from a filtered list of available beds. 631 In the base configuration beds are sorted by the sort id 632 of the hostel and the bed number. The first bed found in 633 this sorted list is taken. 634 """ 635 sorted_beds = sorted(available_beds, 636 key=lambda bed: 1000 * bed.__parent__.sort_id + bed.bed_number) 637 if desired_hostel: 638 # Filter desired hostel beds 639 filtered_beds = [bed for bed in sorted_beds 640 if bed.bed_id.startswith(desired_hostel)] 641 if not filtered_beds: 642 return 643 return filtered_beds[0] 644 return sorted_beds[0] 635 645 636 646 def _admissionText(self, student, portal_language):
Note: See TracChangeset for help on using the changeset viewer.