0001-authenticators-view-show-condition-even-if-empty-654.patch
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 pgettext_lazy |
|
26 | 27 |
from django.utils.translation import ugettext_lazy as _ |
27 | 28 | |
28 | 29 |
from authentic2 import views |
... | ... | |
77 | 78 |
unique = False |
78 | 79 |
protected = False |
79 | 80 |
description_fields = ['show_condition'] |
81 |
empty_field_labels = {'show_condition': pgettext_lazy('show condition', 'None')} |
|
80 | 82 | |
81 | 83 |
class Meta: |
82 | 84 |
ordering = ('-enabled', 'order', 'name', 'slug', 'ou') |
... | ... | |
101 | 103 |
value = getattr(self, 'get_%s_display' % field)() |
102 | 104 |
else: |
103 | 105 |
value = getattr(self, field) |
106 | ||
107 |
value = value or self.empty_field_labels.get(field) |
|
104 | 108 |
if not value: |
105 | 109 |
continue |
106 | 110 |
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 | ||
---|---|---|
46 | 46 |
authenticator = LoginPasswordAuthenticator.objects.get() |
47 | 47 | |
48 | 48 |
resp = resp.click('Configure') |
49 |
assert 'Click "Edit" to change configuration.' in resp.text
|
|
49 |
assert 'Show condition: None' in resp.text
|
|
50 | 50 |
# cannot delete password authenticator |
51 | 51 |
assert 'Delete' not in resp.text |
52 | 52 |
assert 'configuration is not complete' not in resp.text |
53 |
- |