Projet

Général

Profil

0001-authenticators-view-show-condition-even-if-empty-654.patch

Valentin Deniaud, 06 juillet 2022 16:20

Télécharger (3,02 ko)

Voir les différences:

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(-)
src/authentic2/apps/authenticators/models.py
23 23
from django.shortcuts import render, reverse
24 24
from django.utils.formats import date_format
25 25
from django.utils.text import capfirst
26
from django.utils.translation import ugettext_lazy as _
26
from django.utils.translation import ugettext_lazy as _, pgettext_lazy
27 27

  
28 28
from authentic2 import views
29 29
from authentic2.utils.evaluate import evaluate_condition
......
67 67
    unique = False
68 68
    protected = False
69 69
    description_fields = ['show_condition']
70
    empty_field_labels = {'show_condition': pgettext_lazy('show condtion', 'None')}
70 71

  
71 72
    class Meta:
72 73
        ordering = ('-enabled', 'name', 'slug', 'ou')
......
91 92
                value = getattr(self, 'get_%s_display' % field)()
92 93
            else:
93 94
                value = getattr(self, field)
95

  
96
            value = value or self.empty_field_labels.get(field)
94 97
            if not value:
95 98
                continue
96 99

  
src/authentic2/apps/authenticators/templates/authentic2/authenticators/authenticator_detail.html
34 34
  <div class='placeholder'>
35 35
    {% for line in object.get_full_description %}
36 36
      <p>{{ line }}</p>
37
    {% empty %}
38
      <p>{% trans 'Click "Edit" to change configuration.' %}</p>
39 37
    {% endfor %}
40 38
  </div>
41 39
{% endblock %}
tests/test_manager_authenticators.py
45 45
    authenticator = LoginPasswordAuthenticator.objects.get()
46 46

  
47 47
    resp = resp.click('Configure')
48
    assert 'Click "Edit" to change configuration.' in resp.text
48
    assert 'Show condition: None' in resp.text
49 49
    # cannot delete password authenticator
50 50
    assert 'Delete' not in resp.text
51 51
    assert 'configuration is not complete' not in resp.text
52
-