summaryrefslogtreecommitdiff
path: root/jimbrella
diff options
context:
space:
mode:
authorFrederick Yin <fkfd@fkfd.me>2021-10-28 22:07:53 +0800
committerFrederick Yin <fkfd@fkfd.me>2021-10-28 22:07:53 +0800
commit16448c30fb4d01d3ceb8209ea8b640b2601e897d (patch)
treecab1d878d115376555cdbf1ed4f352749d5ab115 /jimbrella
parent2a461c808553bd161c558fedcbd00f70c57d47a5 (diff)
Database keeps admin log
Diffstat (limited to 'jimbrella')
-rw-r--r--jimbrella/database.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/jimbrella/database.py b/jimbrella/database.py
index 9ca3c5b..410985e 100644
--- a/jimbrella/database.py
+++ b/jimbrella/database.py
@@ -1,7 +1,8 @@
from datetime import datetime, timedelta
from .csv_table import CsvTable
+from .admin_log import AdminLog
from .utils import human_datetime, human_timedelta
-from .config import DUE_HOURS
+from .config import DUE_HOURS, ADMIN_LOG_PATH
from .exceptions import *
STATUSES = ["available", "lent", "overdue", "maintenance", "withheld", "unknown"]
@@ -60,6 +61,7 @@ class Database(CsvTable):
},
],
)
+ self.admin_log = AdminLog(ADMIN_LOG_PATH)
def _find_by_serial(self, serial: int) -> dict:
"""Given a serial number, returns an umbrella with such serial.
@@ -208,6 +210,7 @@ class Database(CsvTable):
umb["tenant_email"] = tenant_email
umb["lent_at"] = date
self._update(umb)
+ self.admin_log.log("TAKEAWAY", umb)
def give_back(self, serial) -> None:
"""When a user has returned an umbrella."""
@@ -221,6 +224,7 @@ class Database(CsvTable):
umb[key] = ""
umb["lent_at"] = None
self._update(umb)
+ self.admin_log.log("GIVEBACK", umb)
def mark_overdue(self, serial) -> None:
"""When an umbrella is overdue, change its status to "overdue"."""
@@ -231,3 +235,4 @@ class Database(CsvTable):
raise UmbrellaStatusError
umb["status"] = "overdue"
self._update(umb)
+ self.admin_log.log("OVERDUE", umb)