Ignore:
Timestamp:
4 Nov 2011, 17:33:06 (13 years ago)
Author:
Henrik Bettermann
Message:

Renumber and sort remaining beds correctly.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.sirp/trunk/src/waeup/sirp/hostels/hostel.py

    r6996 r6998  
    5959                self._p_changed = True
    6060                removed_counter += 1
     61            else:
     62                self[key].bed_number = 9999
     63        remaining = len(keys) - removed_counter
    6164
    6265        blocks_for_female = getattr(self,'blocks_for_female',[])
     
    9497                        if self.has_key(uid):
    9598                            bed = self[uid]
     99                            # Renumber remaining beds
     100                            bed.bed_number = len(self) + 1 - remaining
     101                            remaining -= 1
    96102                            if bed.bed_type != bt:
    97103                                bed.bed_type = bt
     
    102108                            bed.bed_id = uid
    103109                            bed.bed_type = bt
    104                             bed.bed_number = len(self) + 1
     110                            bed.bed_number = len(self) + 1 - remaining
    105111                            bed.owner = NOT_OCCUPIED
    106112                            self.addBed(bed)
     
    122128
    123129    def bookBed(self, student_id):
    124         self.owner = student_id
    125         return
     130        if self.owner == NOT_OCCUPIED:
     131            self.owner = student_id
     132            return None
     133        else:
     134            return self.owner
    126135
    127136    def switchReservation(self):
Note: See TracChangeset for help on using the changeset viewer.