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 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'jimbrella/database.py') 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"]: -- cgit v1.2.3