Add a new boolean radios fields and change forms to use it

This adds a new OnOffField class that implements a boolean field
that is rendered as two On / Off radio buttons. This allows us to
avoid comparing 'on' and 'off' string values in the views since
the field takes care of transforming form data into python booleans.

This also adds a form class that can be used for any single On / Off
switch forms (e.g. service permissions).
This commit is contained in:
Alexey Bezhan
2019-02-18 16:27:53 +00:00
parent ddbd4380c9
commit 75fd2d4ffc
3 changed files with 31 additions and 17 deletions

View File

@@ -2518,7 +2518,7 @@ def test_unknown_channel_404s(
'It costs between 30p and 76p to send a letter using Notify.',
'Send letters',
['email', 'sms'],
'off', 'on',
'False', 'True',
['email', 'sms', 'letter'],
),
(
@@ -2526,7 +2526,7 @@ def test_unknown_channel_404s(
'It costs between 30p and 76p to send a letter using Notify.',
'Send letters',
['email', 'sms', 'letter'],
'on', 'off',
'True', 'False',
['email', 'sms'],
),
(
@@ -2534,7 +2534,7 @@ def test_unknown_channel_404s(
'You have a free allowance of 250,000 text messages each financial year.',
'Send text messages',
[],
'off', 'on',
'False', 'True',
['sms'],
),
(
@@ -2542,7 +2542,7 @@ def test_unknown_channel_404s(
'Its free to send emails through GOV.UK Notify.',
'Send emails',
[],
'off', 'on',
'False', 'True',
['email'],
),
(
@@ -2550,7 +2550,7 @@ def test_unknown_channel_404s(
'Its free to send emails through GOV.UK Notify.',
'Send emails',
['email', 'sms', 'letter'],
'on', 'on',
'True', 'True',
['email', 'sms', 'letter'],
),
])