From 722e2e4050b19c363a3ea13337d7fbc7a4bc7551 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Sun, 3 Mar 2019 17:12:35 +0100 Subject: [PATCH] Show warning when un-attached policies exist --- .../admin/templates/administration/overview.html | 12 ++++++++---- .../admin/templates/administration/policy/list.html | 10 +++++++++- passbook/admin/views/overview.py | 1 + 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/passbook/admin/templates/administration/overview.html b/passbook/admin/templates/administration/overview.html index 477b1806c..f749696d6 100644 --- a/passbook/admin/templates/administration/overview.html +++ b/passbook/admin/templates/administration/overview.html @@ -81,7 +81,7 @@ title="{% trans 'No Factors configured. No Users will be able to login.' %}"> {{ factor_count }} {% else %} - {{ worker_count }} + {{ factor_count }} {% endif %}

@@ -99,9 +99,13 @@

- - {{ policy_count }} - + {% if policies_without_attachment > 0 %} + + {{ policy_count }} + {% else %} + {{ policy_count }} + {% endif %}

diff --git a/passbook/admin/templates/administration/policy/list.html b/passbook/admin/templates/administration/policy/list.html index b3949b593..7ed1e102d 100644 --- a/passbook/admin/templates/administration/policy/list.html +++ b/passbook/admin/templates/administration/policy/list.html @@ -28,6 +28,7 @@ + @@ -35,7 +36,14 @@ {% for policy in object_list %} - + +
{% trans 'Name' %} {% trans 'Type' %}
+ {% if not policy.policymodel_set.exists %} + + {% else %} + + {% endif %} + {{ policy.name }} {{ policy|verbose_name }} diff --git a/passbook/admin/views/overview.py b/passbook/admin/views/overview.py index ce32338a7..d2bca417f 100644 --- a/passbook/admin/views/overview.py +++ b/passbook/admin/views/overview.py @@ -24,4 +24,5 @@ class AdministrationOverviewView(AdminRequiredMixin, TemplateView): kwargs['version'] = __version__ kwargs['worker_count'] = len(CELERY_APP.control.ping(timeout=0.5)) kwargs['providers_without_application'] = Provider.objects.filter(application=None) + kwargs['policies_without_attachment'] = len(Policy.objects.filter(policymodel__isnull=True)) return super().get_context_data(**kwargs)