From a2c80e9a02430be73962f4ca83b49e5f80fd3594 Mon Sep 17 00:00:00 2001 From: Frederick Yin Date: Wed, 20 Oct 2021 17:09:50 +0800 Subject: Separate "overdue" from "lent" as a distinct status --- jimbrella/database.py | 5 +++-- jimbrella/web.py | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'jimbrella') diff --git a/jimbrella/database.py b/jimbrella/database.py index ab54a28..014b5b5 100644 --- a/jimbrella/database.py +++ b/jimbrella/database.py @@ -26,6 +26,7 @@ class Database: | "withheld", "unknown") | available : is in service on the stand | lent : is in temporary possession of a user + | overdue : is in overly prolonged possession of a user | maintenance : is on the stand but not in service | withheld : is not on the stand but rather in the possession of an | administrator @@ -169,7 +170,7 @@ class Database: umbrellas = self._read() now = datetime.now() for idx, umb in enumerate(umbrellas): - if umb["status"] == "lent": + if umb["status"] in ("lent", "overdue"): umbrellas[idx]["lent_at_str"] = human_datetime(umb["lent_at"]) lent_time_ago = now - umb["lent_at"] umbrellas[idx]["lent_time_ago"] = lent_time_ago @@ -216,7 +217,7 @@ class Database: umb = self._find_by_serial(serial) if umb is None: raise ValueError(f"No umbrella with serial {serial} found.") - elif umb["status"] != "lent": + elif umb["status"] not in ("lent", "overdue"): raise ValueError(f"Umbrella with serial {serial} is not lent out.") umb["status"] = "available" for key in ["tenant_name", "tenant_id", "tenant_phone", "tenant_email"]: diff --git a/jimbrella/web.py b/jimbrella/web.py index e2de758..73b0659 100644 --- a/jimbrella/web.py +++ b/jimbrella/web.py @@ -16,7 +16,7 @@ def admin_index(): umbrellas=umbrellas, available=statuses["available"], lent=statuses["lent"], - overdue=Database.find_overdue(statuses["lent"]), + overdue=statuses["overdue"], ) -- cgit v1.2.3