summaryrefslogtreecommitdiff
path: root/jimbrella/database.py
diff options
context:
space:
mode:
Diffstat (limited to 'jimbrella/database.py')
-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)