From d41dc9044ce57fd53d096899c0f1a64c500b31ee Mon Sep 17 00:00:00 2001 From: Adam Goldsmith Date: Thu, 27 Jan 2022 16:28:26 -0500 Subject: [PATCH] rentals: Add `__str__()` for LockerUnit --- rentals/models.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/rentals/models.py b/rentals/models.py index 58938cb..8fc8d8b 100644 --- a/rentals/models.py +++ b/rentals/models.py @@ -35,6 +35,11 @@ class LockerUnit(models.Model): ] 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: return chr(column + ord(self.first_letter))