Fix: extra_fields now returns BoundField (#7801)

pull/7825/head
Michael Karamuth 2021-12-19 14:20:13 +04:00 zatwierdzone przez Matt Westcott
rodzic 946a9a8071
commit fd29f0b9bb
3 zmienionych plików z 11 dodań i 3 usunięć

Wyświetl plik

@ -21,9 +21,9 @@ class LoginForm(AuthenticationForm):
@property
def extra_fields(self):
for field_name, field in self.fields.items():
for field_name in self.fields.keys():
if field_name not in ['username', 'password']:
yield field_name, field
yield field_name, self[field_name]
class PasswordResetForm(DjangoPasswordResetForm):

Wyświetl plik

@ -14,5 +14,5 @@ class TestLoginForm(TestCase):
def test_extra_fields(self):
form = CustomLoginForm()
self.assertEqual(list(form.extra_fields), [
('captcha', form.fields['captcha'])
('captcha', form['captcha'])
])

Wyświetl plik

@ -60,3 +60,11 @@ class TestLoginView(TestCase, WagtailTestUtils):
def test_bidi_language_changes_dir_attribute(self):
response = self.client.get(reverse('wagtailadmin_login'))
self.assertContains(response, '<html class="no-js" lang="he" dir="rtl">')
@override_settings(WAGTAILADMIN_USER_LOGIN_FORM="wagtail.admin.tests.test_forms.CustomLoginForm")
def test_login_page_renders_extra_fields(self):
response = self.client.get(reverse('wagtailadmin_login'))
form = response.context['form']
expected_widget = str(form['captcha'])
self.assertInHTML(expected_widget, str(response.content))