Bump WTForms to 2.3.1

This involves three changes which broke our code.

To validate email addresses, the optional dependency `email-validator`
must be installed<sup>1</sup>. But since we don’t use WTForms’ email
validation, we shouldn’t need to subclass it – it can just be its own
self contained thing. Then we don’t need to add the extra dependency.

When rendering textareas, and extra `\r\n` is inserted at the beginning
<sup>2</sup>. Browsers will strip this when displaying the textbox and
submitting the form, but some of our tests need updating to account for
this.

The error message for when you don’t choose an option from some radio
buttons has now changed. Rather than just accepting WTForms’ new
message, this commit makes the error messages like the examples from
the Design System<sup>3</sup>. By default it will say ‘Select an
option’, but by passing in an extra parameter (`thing`) it can be
customised to be more specific, for example ‘Select a type of
organisation’.

***

1. https://github.com/wtforms/wtforms/pull/429
2. https://github.com/wtforms/wtforms/issues/238
3. https://design-system.service.gov.uk/components/radios/#error-messages
This commit is contained in:
Chris Hill-Scott
2020-04-22 17:49:03 +01:00
parent bc4f2166cd
commit 65bb72ef2f
14 changed files with 62 additions and 53 deletions

View File

@@ -792,7 +792,7 @@ def test_clear_cache_requires_option(client_request, platform_admin_user, mocker
page = client_request.post('main.clear_cache', _data={}, _expected_status=200)
assert normalize_spaces(page.find('span', class_='error-message').text) == 'Not a valid choice'
assert normalize_spaces(page.find('span', class_='error-message').text) == 'Select an option'
assert not redis.delete_cache_keys_by_pattern.called