From 4ab9246ecb4ab43ba0ac0c69f93b776f3fe0cfff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sondre=20Gr=C3=B8n=C3=A5s?= <44143748+sondregronas@users.noreply.github.com> Date: Thu, 24 Aug 2023 16:33:03 +0200 Subject: [PATCH] Add due date to items mail_repr --- BookingSystem/inventory.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/BookingSystem/inventory.py b/BookingSystem/inventory.py index 55b178b..d74a2c4 100644 --- a/BookingSystem/inventory.py +++ b/BookingSystem/inventory.py @@ -57,13 +57,19 @@ def api_repr(self) -> dict: } def mail_repr(self) -> str: - return f'{self.lender_name}: {self.id} {self.name} ({self.category})' + return f'{self.lender_name}: {self.id} {self.name} ({self.category}, Frist: {self.order_due_date_fmt})' def __str__(self) -> str: if self.order_due_date: - return f'{self.lender_name}: {self.id} - {self.name} ({self.category}, {parser.parse(self.order_due_date):%d.%m.%Y})' + return f'{self.lender_name}: {self.id} - {self.name} ({self.category}, {self.order_due_date_fmt})' return f'{self.id} - {self.name} - {self.category}' + @property + def order_due_date_fmt(self) -> str: + if not self.order_due_date: + return '' + return parser.parse(self.order_due_date).strftime('%d.%m.%Y') + @property def user(self) -> dict: if self.borrowed_to is None: