diff options
Diffstat (limited to 'tests/admin_views')
| -rw-r--r-- | tests/admin_views/customadmin.py | 1 | ||||
| -rw-r--r-- | tests/admin_views/forms.py | 8 | ||||
| -rw-r--r-- | tests/admin_views/tests.py | 5 |
3 files changed, 13 insertions, 1 deletions
diff --git a/tests/admin_views/customadmin.py b/tests/admin_views/customadmin.py index 4b30c5c30f..a63d24a9ee 100644 --- a/tests/admin_views/customadmin.py +++ b/tests/admin_views/customadmin.py @@ -18,6 +18,7 @@ class Admin2(admin.AdminSite): login_template = "custom_admin/login.html" logout_template = "custom_admin/logout.html" index_template = ["custom_admin/index.html"] # a list, to test fix for #18697 + password_change_form = forms.CustomAdminPasswordChangeForm password_change_template = "custom_admin/password_change_form.html" password_change_done_template = "custom_admin/password_change_done.html" diff --git a/tests/admin_views/forms.py b/tests/admin_views/forms.py index e9d9c0a8a5..3a3566c10f 100644 --- a/tests/admin_views/forms.py +++ b/tests/admin_views/forms.py @@ -1,4 +1,4 @@ -from django.contrib.admin.forms import AdminAuthenticationForm +from django.contrib.admin.forms import AdminAuthenticationForm, AdminPasswordChangeForm from django.contrib.admin.helpers import ActionForm from django.core.exceptions import ValidationError @@ -14,6 +14,12 @@ class CustomAdminAuthenticationForm(AdminAuthenticationForm): return username +class CustomAdminPasswordChangeForm(AdminPasswordChangeForm): + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + self.fields["old_password"].label = "Custom old password label" + + class MediaActionForm(ActionForm): class Media: js = ["path/to/media.js"] diff --git a/tests/admin_views/tests.py b/tests/admin_views/tests.py index 7642a186c0..ec6fd58d53 100644 --- a/tests/admin_views/tests.py +++ b/tests/admin_views/tests.py @@ -1820,6 +1820,11 @@ class AdminCustomTemplateTests(AdminViewBasicTestCase): response = user_admin.user_change_password(request, str(user.pk)) self.assertContains(response, '<div class="help">') + def test_custom_password_change_form(self): + self.client.force_login(self.superuser) + response = self.client.get(reverse("admin4:password_change")) + self.assertContains(response, "Custom old password label") + def test_extended_bodyclass_template_index(self): """ The admin/index.html template uses block.super in the bodyclass block. |
