Ignore:
Timestamp:
12 Nov 2015, 06:30:43 (9 years ago)
Author:
Henrik Bettermann
Message:

Sort available bed. Beds are sorted by the sort id of the hostel and the bed number.
The first bed found in this sorted list is taken.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.uniben/trunk/src/waeup/uniben/students/utils.py

    r13441 r13444  
    384384    def selectBed(self, available_beds):
    385385        """Select a bed from a list of available beds.
    386         In the base configuration we select the first bed found,
    387         but can also randomize the selection if we like.
    388         """
    389         return available_beds[0]
     386        Beds are sorted by the sort id of the hostel and the bed number.
     387        The first bed found in this sorted list is taken.
     388        """
     389        sorted_beds = sorted(available_beds,
     390            key=lambda bed: 1000 * bed.__parent__.sort_id + bed.bed_number)
     391        return sorted_beds[0]
    390392
    391393    # Uniben prefix
Note: See TracChangeset for help on using the changeset viewer.