rentals: Add __str__() for LockerUnit

This commit is contained in:
Adam Goldsmith 2022-01-27 16:28:26 -05:00
parent b956812e67
commit d41dc9044c

View File

@ -35,6 +35,11 @@ class LockerUnit(models.Model):
] ]
ordering = ["index"] ordering = ["index"]
def __str__(self):
last_letter = chr(ord(self.first_letter) + self.columns - 1)
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})"
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))