Show warning when un-attached policies exist

This commit is contained in:
Jens Langhammer 2019-03-03 17:12:35 +01:00
parent 20ad062814
commit 722e2e4050
3 changed files with 18 additions and 5 deletions

View File

@ -81,7 +81,7 @@
title="{% trans 'No Factors configured. No Users will be able to login.' %}"></span>
{{ factor_count }}
{% else %}
<span class="pficon pficon-ok"></span>{{ worker_count }}
<span class="pficon pficon-ok"></span>{{ factor_count }}
{% endif %}
</span>
</p>
@ -99,9 +99,13 @@
<div class="card-pf-body">
<p class="card-pf-aggregate-status-notifications">
<span class="card-pf-aggregate-status-notification">
<a href="{% url 'passbook_admin:policies' %}">
{% if policies_without_attachment > 0 %}
<span class="pficon-warning-triangle-o" data-toggle="tooltip" data-placement="right"
title="{% trans 'Policies without attachment exist.' %}"></span>
{{ policy_count }}
{% else %}
<span class="pficon pficon-ok"></span>{{ policy_count }}
</a>
{% endif %}
</span>
</p>
</div>

View File

@ -28,6 +28,7 @@
<table class="table table-striped table-bordered">
<thead>
<tr>
<th></th>
<th>{% trans 'Name' %}</th>
<th>{% trans 'Type' %}</th>
<th></th>
@ -35,7 +36,14 @@
</thead>
<tbody>
{% for policy in object_list %}
<tr>
<tr {% if not policy.policymodel_set.exists %} class="warning" {% endif %}>
<th>
{% if not policy.policymodel_set.exists %}
<span class="pficon-warning-triangle-o" data-toggle="tooltip" data-placement="right" title="{% trans 'Warning: Policy is not assigned.' %}"></span>
{% else %}
<span class="pficon-ok" data-toggle="tooltip" data-placement="right" title="{% blocktrans with objects=policy.policymodel_set.all|join:', ' %}Assigned to objects {{ objects }}{% endblocktrans %}"></span>
{% endif %}
</th>
<td>{{ policy.name }}</td>
<td>{{ policy|verbose_name }}</td>
<td>

View File

@ -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)