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:
parent
946a9a8071
commit
fd29f0b9bb
@ -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):
|
||||
|
@ -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'])
|
||||
])
|
||||
|
@ -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))
|
||||
|
Loading…
Reference in New Issue
Block a user