mirror of
https://github.com/django/django.git
synced 2025-03-06 07:22:32 +00:00
Fixed #34656 -- Fixed unclosed div in admin password change template.
Regression in 6991880109e35c879b71b7d9d9c154baeec12b89.
This commit is contained in:
parent
bcacc6321a
commit
3f1bc2222f
@ -34,7 +34,7 @@
|
||||
{{ form.password1.errors }}
|
||||
<div class="flex-container">{{ form.password1.label_tag }} {{ form.password1 }}</div>
|
||||
{% if form.password1.help_text %}
|
||||
<div class="help"{% if form.password1.id_for_label %} id="{{ form.password1.id_for_label }}_helptext">{% endif %}{{ form.password1.help_text|safe }}</div>
|
||||
<div class="help"{% if form.password1.id_for_label %} id="{{ form.password1.id_for_label }}_helptext"{% endif %}>{{ form.password1.help_text|safe }}</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
|
@ -6,6 +6,7 @@ import zoneinfo
|
||||
from unittest import mock
|
||||
from urllib.parse import parse_qsl, urljoin, urlparse
|
||||
|
||||
from django import forms
|
||||
from django.contrib import admin
|
||||
from django.contrib.admin import AdminSite, ModelAdmin
|
||||
from django.contrib.admin.helpers import ACTION_CHECKBOX_NAME
|
||||
@ -16,6 +17,8 @@ from django.contrib.admin.tests import AdminSeleniumTestCase
|
||||
from django.contrib.admin.utils import quote
|
||||
from django.contrib.admin.views.main import IS_POPUP_VAR
|
||||
from django.contrib.auth import REDIRECT_FIELD_NAME, get_permission_codename
|
||||
from django.contrib.auth.admin import UserAdmin
|
||||
from django.contrib.auth.forms import AdminPasswordChangeForm
|
||||
from django.contrib.auth.models import Group, Permission, User
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.core import mail
|
||||
@ -25,6 +28,7 @@ from django.db import connection
|
||||
from django.forms.utils import ErrorList
|
||||
from django.template.response import TemplateResponse
|
||||
from django.test import (
|
||||
RequestFactory,
|
||||
TestCase,
|
||||
ignore_warnings,
|
||||
modify_settings,
|
||||
@ -1652,6 +1656,29 @@ class AdminCustomTemplateTests(AdminViewBasicTestCase):
|
||||
"Enter the same password as before, for verification.</div>",
|
||||
)
|
||||
|
||||
def test_change_password_template_helptext_no_id(self):
|
||||
user = User.objects.get(username="super")
|
||||
|
||||
class EmptyIdForLabelTextInput(forms.TextInput):
|
||||
def id_for_label(self, id):
|
||||
return None
|
||||
|
||||
class EmptyIdForLabelHelpTextPasswordChangeForm(AdminPasswordChangeForm):
|
||||
password1 = forms.CharField(
|
||||
help_text="Your new password", widget=EmptyIdForLabelTextInput()
|
||||
)
|
||||
|
||||
class CustomUserAdmin(UserAdmin):
|
||||
change_password_form = EmptyIdForLabelHelpTextPasswordChangeForm
|
||||
|
||||
request = RequestFactory().get(
|
||||
reverse("admin:auth_user_password_change", args=(user.id,))
|
||||
)
|
||||
request.user = user
|
||||
user_admin = CustomUserAdmin(User, site)
|
||||
response = user_admin.user_change_password(request, str(user.pk))
|
||||
self.assertContains(response, '<div class="help">')
|
||||
|
||||
def test_extended_bodyclass_template_index(self):
|
||||
"""
|
||||
The admin/index.html template uses block.super in the bodyclass block.
|
||||
|
Loading…
x
Reference in New Issue
Block a user