From cf1e682c8c68d7187c34f46f2717b22f830d92a1 Mon Sep 17 00:00:00 2001 From: Tim Graham Date: Wed, 19 Apr 2017 12:59:30 -0400 Subject: [PATCH] [1.11.x] Fixed #28097 -- Fixed layout of ReadOnlyPasswordHashWidget. Backport of dff559ff83a6aac14de0bbca58101786edf4195f from master --- .../auth/widgets/read_only_password_hash.html | 4 +++- docs/releases/1.11.1.txt | 3 +++ tests/auth_tests/test_forms.py | 16 ++++++++++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/django/contrib/auth/templates/auth/widgets/read_only_password_hash.html b/django/contrib/auth/templates/auth/widgets/read_only_password_hash.html index b411298d74..a2a12c6f10 100644 --- a/django/contrib/auth/templates/auth/widgets/read_only_password_hash.html +++ b/django/contrib/auth/templates/auth/widgets/read_only_password_hash.html @@ -1,3 +1,5 @@ + {% for entry in summary %} -{{ entry.label }}{% if entry.value %}: {{ entry.value }}{% endif %} +{{ entry.label }}{% if entry.value %}: {{ entry.value }}{% endif %} {% endfor %} + diff --git a/docs/releases/1.11.1.txt b/docs/releases/1.11.1.txt index 41f82a0c63..26ff892731 100644 --- a/docs/releases/1.11.1.txt +++ b/docs/releases/1.11.1.txt @@ -30,3 +30,6 @@ Bugfixes * Prevented ``SessionBase.cycle_key()`` from losing session data if ``_session_cache`` isn't populated (:ticket:`28066`). + +* Fixed layout of ``ReadOnlyPasswordHashWidget`` (used in the admin's user + change page) (:ticket:`28097`). diff --git a/tests/auth_tests/test_forms.py b/tests/auth_tests/test_forms.py index cc77288f56..4bfc3d11e7 100644 --- a/tests/auth_tests/test_forms.py +++ b/tests/auth_tests/test_forms.py @@ -834,6 +834,22 @@ class ReadOnlyPasswordHashTest(SimpleTestCase): html = widget.render(name='password', value=None, attrs={}) 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'}), + """ +
+ algorithm: pbkdf2_sha256 + iterations: 100000 + salt: a6Pucb****** + hash: WmCkn9************************************** +
+ """ + ) + def test_readonly_field_has_changed(self): field = ReadOnlyPasswordHashField() self.assertFalse(field.has_changed('aaa', 'bbb'))