From bdce60fce610fb6f73ca8e9440254ab3b4461655 Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Fri, 11 Nov 2022 19:26:36 -0800 Subject: [PATCH] Add statistics with object counts to admin page. --- .../backend/endpoints/admin_endpoints.py | 10 +++++++++- frontends/etiquette_flask/templates/admin.html | 8 ++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/frontends/etiquette_flask/backend/endpoints/admin_endpoints.py b/frontends/etiquette_flask/backend/endpoints/admin_endpoints.py index 72b2d56..02f15ad 100644 --- a/frontends/etiquette_flask/backend/endpoints/admin_endpoints.py +++ b/frontends/etiquette_flask/backend/endpoints/admin_endpoints.py @@ -1,5 +1,6 @@ import flask; from flask import request +from voussoirkit import dotdict from voussoirkit import flasktools from voussoirkit import timetools @@ -17,7 +18,14 @@ def get_admin(): if not request.is_localhost: flask.abort(403) - return common.render_template(request, 'admin.html') + counts = dotdict.DotDict({ + 'albums': common.P.get_album_count(), + 'bookmarks': common.P.get_bookmark_count(), + 'photos': common.P.get_photo_count(), + 'tags': common.P.get_tag_count(), + 'users': common.P.get_user_count(), + }) + return common.render_template(request, 'admin.html', counts=counts) @site.route('/admin/dbdownload') def get_dbdump(): diff --git a/frontends/etiquette_flask/templates/admin.html b/frontends/etiquette_flask/templates/admin.html index df18985..1616150 100644 --- a/frontends/etiquette_flask/templates/admin.html +++ b/frontends/etiquette_flask/templates/admin.html @@ -28,6 +28,14 @@

Download database file

+
+

Statistics

+

{{counts.albums}} albums

+

{{counts.bookmarks}} bookmarks

+

{{counts.photos}} photos

+

{{counts.tags}} tags

+

{{counts.users}} users

+