0
0
mirror of https://github.com/wagtail/wagtail.git synced 2024-12-01 11:41:20 +01:00

Fix: extra_fields now returns BoundField (#7801)

This commit is contained in:
Michael Karamuth 2021-12-19 14:20:13 +04:00 committed by Matt Westcott
parent 946a9a8071
commit fd29f0b9bb
3 changed files with 11 additions and 3 deletions

View File

@ -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):

View File

@ -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'])
])

View File

@ -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))