Ignore:
Timestamp:
17 Nov 2008, 16:55:29 (16 years ago)
Author:
Henrik Bettermann
Message:

enable random bed booking order

File:
1 edited

Legend:

Unmodified
Added
Removed
  • WAeUP_SRP/trunk/WAeUPTables.py

    r3757 r3772  
    491491        WAeUPTable.__init__(self, name)
    492492
    493     def searchAndReserveBed(self, student_id,bed_type): ###(
     493    def searchAndReserveBed(self, student_id,bed_type,random_order=False): ###(
    494494        logger = logging.getLogger('WAeUPTables.AccommodationTable.searchAndReserveBed')
    495495        records = self.evalAdvancedQuery(Eq('student',student_id))
     
    506506            logger.info('no bed %s available for %s' % (bed_type,student_id))
    507507            return -2,"no bed"
    508         rec = records[0]
     508        if random_order:
     509            import random
     510            bed_no = random.randint(0,len(records)-1)
     511        else:
     512            bed_no = 0
     513        rec = records[bed_no]
    509514        self.modifyRecord(bed=rec.bed,student=student_id)
    510515        logger.info('%s booked bed %s' % (student_id,rec.bed))
Note: See TracChangeset for help on using the changeset viewer.