From 1130c23b1e6bb1e4db71c41f5e4add903267830e Mon Sep 17 00:00:00 2001 From: Andrew Godwin Date: Thu, 15 Dec 2022 12:26:17 -0700 Subject: Stator stats overhaul Removes the error table, adds a stats table and admin page. Fixes #166 --- users/views/admin/__init__.py | 1 + users/views/admin/stator.py | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 users/views/admin/stator.py (limited to 'users/views/admin') diff --git a/users/views/admin/__init__.py b/users/views/admin/__init__.py index b8ebc40..bb70ff7 100644 --- a/users/views/admin/__init__.py +++ b/users/views/admin/__init__.py @@ -22,6 +22,7 @@ from users.views.admin.settings import ( # noqa PoliciesSettings, TuningSettings, ) +from users.views.admin.stator import Stator # noqa @method_decorator(admin_required, name="dispatch") diff --git a/users/views/admin/stator.py b/users/views/admin/stator.py new file mode 100644 index 0000000..c3ce01d --- /dev/null +++ b/users/views/admin/stator.py @@ -0,0 +1,20 @@ +from django.utils.decorators import method_decorator +from django.views.generic import TemplateView + +from stator.models import StatorModel, Stats +from users.decorators import admin_required + + +@method_decorator(admin_required, name="dispatch") +class Stator(TemplateView): + + template_name = "admin/stator.html" + + def get_context_data(self): + return { + "model_stats": { + model._meta.verbose_name_plural.title(): Stats.get_for_model(model) + for model in StatorModel.subclasses + }, + "section": "stator", + } -- cgit v1.2.3