diff options
author | Frederick Yin <fkfd@fkfd.me> | 2021-10-20 16:31:16 +0800 |
---|---|---|
committer | Frederick Yin <fkfd@fkfd.me> | 2021-10-20 16:31:16 +0800 |
commit | 06b15c08c1b78adf9e26eb738b7a3964199989f1 (patch) | |
tree | b9d8a2c78112ccdd3846166e46d80a26401aa2f1 /jimbrella/database.py | |
parent | 27c8be28e00fbf110143d4bc4b949c610f704639 (diff) |
Add page /admin/umbrellas
Lists all umbrellas in a table.
Diffstat (limited to 'jimbrella/database.py')
-rw-r--r-- | jimbrella/database.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/jimbrella/database.py b/jimbrella/database.py index 7f10c55..ab54a28 100644 --- a/jimbrella/database.py +++ b/jimbrella/database.py @@ -1,7 +1,7 @@ import csv import os from datetime import datetime, timedelta -from .utils import human_timedelta +from .utils import human_datetime, human_timedelta from .config import DUE_HOURS @@ -161,14 +161,16 @@ class Database: All exposed methods with a return value should use this method instead of `_read()`. Supplemental data: + - lent_at_str: string representation for lent_at. - lent_time_ago: time since umbrella was taken away by tenant. if umbrella is not taken away, its value is None. - - lent_time_ago_str: lent_time_ago as a string representation. + - lent_time_ago_str: string representation for lent_time_ago. """ umbrellas = self._read() now = datetime.now() for idx, umb in enumerate(umbrellas): if umb["status"] == "lent": + 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 umbrellas[idx]["lent_time_ago_str"] = human_timedelta(lent_time_ago) |