rentals: Reverse ordering of locker numbers

Because for some reason, our lockers are numbered right to left
This commit is contained in:
Adam Goldsmith 2022-01-28 15:59:54 -05:00
parent d41dc9044c
commit bd9ce2457b

View File

@ -38,13 +38,13 @@ class LockerUnit(models.Model):
def __str__(self): def __str__(self):
last_letter = chr(ord(self.first_letter) + self.columns - 1) last_letter = chr(ord(self.first_letter) + self.columns - 1)
last_number = self.first_number + self.columns * self.rows last_number = self.first_number + self.columns * self.rows
return f"{self.bank.name} (Unit {self.first_letter}{self.first_number}-{last_letter}{last_number})" return f"{self.bank.name} (Unit {last_letter}{self.first_number}-{self.first_letter}{last_number})"
def letter_for_column(self, column: int) -> str: def letter_for_column(self, column: int) -> str:
return chr(column + ord(self.first_letter)) return chr(column + ord(self.first_letter))
def number_for_locker(self, column: int, row: int) -> int: def number_for_locker(self, column: int, row: int) -> int:
return row + self.first_number + column * self.rows return row + self.first_number + (self.columns - column - 1) * self.rows
@property @property
def iter_doors(self): def iter_doors(self):