Fixed #28097 -- Fixed layout of ReadOnlyPasswordHashWidget.

This commit is contained in:
Tim Graham 2017-04-19 12:59:30 -04:00 committed by GitHub
parent cd7afcdcac
commit dff559ff83
3 changed files with 22 additions and 1 deletions

View File

@ -1,3 +1,5 @@
<div{% include 'django/forms/widgets/attrs.html' %}>
{% for entry in summary %} {% for entry in summary %}
<div{% include 'django/forms/widgets/attrs.html' %}><strong>{{ entry.label }}</strong>{% if entry.value %}: {{ entry.value }}{% endif %} <strong>{{ entry.label }}</strong>{% if entry.value %}: {{ entry.value }}{% endif %}
{% endfor %} {% endfor %}
</div>

View File

@ -30,3 +30,6 @@ Bugfixes
* Prevented ``SessionBase.cycle_key()`` from losing session data if * Prevented ``SessionBase.cycle_key()`` from losing session data if
``_session_cache`` isn't populated (:ticket:`28066`). ``_session_cache`` isn't populated (:ticket:`28066`).
* Fixed layout of ``ReadOnlyPasswordHashWidget`` (used in the admin's user
change page) (:ticket:`28097`).

View File

@ -825,6 +825,22 @@ class ReadOnlyPasswordHashTest(SimpleTestCase):
html = widget.render(name='password', value=None, attrs={}) html = widget.render(name='password', value=None, attrs={})
self.assertIn(_("No password set."), html) self.assertIn(_("No password set."), html)
@override_settings(PASSWORD_HASHERS=['django.contrib.auth.hashers.PBKDF2PasswordHasher'])
def test_render(self):
widget = ReadOnlyPasswordHashWidget()
value = 'pbkdf2_sha256$100000$a6Pucb1qSFcD$WmCkn9Hqidj48NVe5x0FEM6A9YiOqQcl/83m2Z5udm0='
self.assertHTMLEqual(
widget.render('name', value, {'id': 'id_password'}),
"""
<div id="id_password">
<strong>algorithm</strong>: pbkdf2_sha256
<strong>iterations</strong>: 100000
<strong>salt</strong>: a6Pucb******
<strong>hash</strong>: WmCkn9**************************************
</div>
"""
)
def test_readonly_field_has_changed(self): def test_readonly_field_has_changed(self):
field = ReadOnlyPasswordHashField() field = ReadOnlyPasswordHashField()
self.assertFalse(field.has_changed('aaa', 'bbb')) self.assertFalse(field.has_changed('aaa', 'bbb'))