From b4134fb5d30509dfd417684bfa3f80da8ae76b0f Mon Sep 17 00:00:00 2001 From: Valentin Deniaud Date: Tue, 7 Jun 2022 14:30:42 +0200 Subject: [PATCH] authenticators: view show condition even if empty (#65478) --- src/authentic2/apps/authenticators/models.py | 5 ++++- .../authentic2/authenticators/authenticator_detail.html | 2 -- tests/test_manager_authenticators.py | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/authentic2/apps/authenticators/models.py b/src/authentic2/apps/authenticators/models.py index ecc8cc19..23cd716c 100644 --- a/src/authentic2/apps/authenticators/models.py +++ b/src/authentic2/apps/authenticators/models.py @@ -23,7 +23,7 @@ from django.db import models from django.shortcuts import render, reverse from django.utils.formats import date_format from django.utils.text import capfirst -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import ugettext_lazy as _, pgettext_lazy from authentic2 import views from authentic2.utils.evaluate import evaluate_condition @@ -67,6 +67,7 @@ class BaseAuthenticator(models.Model): unique = False protected = False description_fields = ['show_condition'] + empty_field_labels = {'show_condition': pgettext_lazy('show condtion', 'None')} class Meta: ordering = ('-enabled', 'name', 'slug', 'ou') @@ -91,6 +92,8 @@ class BaseAuthenticator(models.Model): value = getattr(self, 'get_%s_display' % field)() else: value = getattr(self, field) + + value = value or self.empty_field_labels.get(field) if not value: continue diff --git a/src/authentic2/apps/authenticators/templates/authentic2/authenticators/authenticator_detail.html b/src/authentic2/apps/authenticators/templates/authentic2/authenticators/authenticator_detail.html index 2738cee5..42c72f1c 100644 --- a/src/authentic2/apps/authenticators/templates/authentic2/authenticators/authenticator_detail.html +++ b/src/authentic2/apps/authenticators/templates/authentic2/authenticators/authenticator_detail.html @@ -34,8 +34,6 @@
{% for line in object.get_full_description %}

{{ line }}

- {% empty %} -

{% trans 'Click "Edit" to change configuration.' %}

{% endfor %}
{% endblock %} diff --git a/tests/test_manager_authenticators.py b/tests/test_manager_authenticators.py index 57eccf8d..1d71437c 100644 --- a/tests/test_manager_authenticators.py +++ b/tests/test_manager_authenticators.py @@ -45,7 +45,7 @@ def test_authenticators_password(app, superuser): authenticator = LoginPasswordAuthenticator.objects.get() resp = resp.click('Configure') - assert 'Click "Edit" to change configuration.' in resp.text + assert 'Show condition: None' in resp.text # cannot delete password authenticator assert 'Delete' not in resp.text assert 'configuration is not complete' not in resp.text -- 2.30.2