summaryrefslogtreecommitdiff
path: root/jimbrella
diff options
context:
space:
mode:
authorFrederick Yin <fkfd@fkfd.me>2021-10-20 17:09:50 +0800
committerFrederick Yin <fkfd@fkfd.me>2021-10-20 17:09:50 +0800
commita2c80e9a02430be73962f4ca83b49e5f80fd3594 (patch)
tree0d5cedf03cc64e4c9f8c5f773b3c6512309946f6 /jimbrella
parent06b15c08c1b78adf9e26eb738b7a3964199989f1 (diff)
Separate "overdue" from "lent" as a distinct status
Diffstat (limited to 'jimbrella')
-rw-r--r--jimbrella/database.py5
-rw-r--r--jimbrella/web.py2
2 files changed, 4 insertions, 3 deletions
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"],
)