From 06b15c08c1b78adf9e26eb738b7a3964199989f1 Mon Sep 17 00:00:00 2001 From: Frederick Yin Date: Wed, 20 Oct 2021 16:31:16 +0800 Subject: Add page /admin/umbrellas Lists all umbrellas in a table. --- jimbrella/database.py | 6 +++-- jimbrella/static/jimbrella.css | 2 +- jimbrella/templates/admin/index.html | 12 ++++++++-- jimbrella/templates/admin/umbrellas.html | 40 ++++++++++++++++++++++++++++++++ jimbrella/utils.py | 17 ++++++++++---- jimbrella/web.py | 11 ++++++++- 6 files changed, 78 insertions(+), 10 deletions(-) create mode 100644 jimbrella/templates/admin/umbrellas.html (limited to 'jimbrella') 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) diff --git a/jimbrella/static/jimbrella.css b/jimbrella/static/jimbrella.css index f9ef7ae..8bb7fbd 100644 --- a/jimbrella/static/jimbrella.css +++ b/jimbrella/static/jimbrella.css @@ -38,7 +38,7 @@ h2.tile-heading, h2.banner-heading { margin-bottom: 2em; } -table { +table.data { border: 2px solid; } diff --git a/jimbrella/templates/admin/index.html b/jimbrella/templates/admin/index.html index 7a62a14..ddbe4e5 100644 --- a/jimbrella/templates/admin/index.html +++ b/jimbrella/templates/admin/index.html @@ -2,18 +2,26 @@ JI Umbrella - +

JI Umbrella Overview

+
+ + + + + +
OverviewAll
+