diff options
author | Frederick Yin <fkfd@fkfd.me> | 2022-02-02 11:33:48 +0800 |
---|---|---|
committer | Frederick Yin <fkfd@fkfd.me> | 2022-02-02 11:33:48 +0800 |
commit | ac73e8544697a63370b4728188d59df809faf197 (patch) | |
tree | bcb2f2aebb13ee8fe31d40616dc7fc3a83bdb3fd /jimbrella/admin.py | |
parent | 3ced6cc3bd7759fcab4c193d72bea09054d4b742 (diff) |
Umbrella count on admin page is done in core, not Jinja
Diffstat (limited to 'jimbrella/admin.py')
-rw-r--r-- | jimbrella/admin.py | 12 |
1 files changed, 6 insertions, 6 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, ) |