summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--jimbrella/admin.py12
-rw-r--r--jimbrella/templates/admin/index.html6
2 files changed, 9 insertions, 9 deletions
diff --git a/jimbrella/admin.py b/jimbrella/admin.py
index 4454c69..8a52bb8 100644
--- a/jimbrella/admin.py
+++ b/jimbrella/admin.py
@@ -29,16 +29,16 @@ def check_privilege():
def index():
umbrellas = db.read()
# count # of umbrellas in each status
- statuses = {
+ status_count = {
status: len([u for u in umbrellas if u["status"] == status])
for status in ("available", "lent", "overdue")
}
return render_template(
"admin/index.html",
- umbrellas=umbrellas,
- available=statuses["available"],
- lent=statuses["lent"],
- overdue=statuses["overdue"],
+ umbrellas=len(umbrellas),
+ available=status_count["available"],
+ lent=status_count["lent"],
+ overdue=status_count["overdue"],
mobile=user_agent(request.user_agent.string).is_mobile,
)
@@ -56,7 +56,7 @@ def umbrellas():
return render_template(
template,
umbrellas=umbrellas,
- edit=int(edit) if edit.isnumeric() else None,
+ edit=int(edit) if edit is not None and edit.isnumeric() else None,
error=error,
)
diff --git a/jimbrella/templates/admin/index.html b/jimbrella/templates/admin/index.html
index 940f2c2..73ae5f6 100644
--- a/jimbrella/templates/admin/index.html
+++ b/jimbrella/templates/admin/index.html
@@ -15,7 +15,7 @@
<div class="banner overdue">
<h2 class="banner-heading">Overdue</h2>
<span class="proportion">
- <strong class="big">{{ overdue|length }}</strong> / {{ umbrellas|length }}
+ <strong class="big">{{ overdue }}</strong> / {{ umbrellas }}
</span>
<div class="table-container">
{% if mobile %}
@@ -64,13 +64,13 @@
<div class="tile lent">
<h2 class="tile-heading">Lent</h2>
<span class="proportion">
- <strong class="big">{{ lent|length }}</strong> / {{ umbrellas|length }}
+ <strong class="big">{{ lent }}</strong> / {{ umbrellas }}
</span>
</div>
<div class="tile available">
<h2 class="tile-heading">Available</h2>
<span class="proportion">
- <strong class="big">{{ available|length }}</strong> / {{ umbrellas|length }}
+ <strong class="big">{{ available }}</strong> / {{ umbrellas }}
</span>
</div>
</div>