From ac73e8544697a63370b4728188d59df809faf197 Mon Sep 17 00:00:00 2001 From: Frederick Yin Date: Wed, 2 Feb 2022 11:33:48 +0800 Subject: Umbrella count on admin page is done in core, not Jinja --- jimbrella/admin.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'jimbrella/admin.py') 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, ) -- cgit v1.2.3