Update all single field checkboxes

Includes adding some code to govukCheckboxesField
to add a single boolean-like option by default, if
there are no choices added.
This commit is contained in:
Tom Byers
2020-04-09 16:31:19 +01:00
parent 2cdea66c88
commit d1ae3b812a
10 changed files with 17 additions and 30 deletions

View File

@@ -1339,7 +1339,7 @@ class ServiceContactDetailsForm(StripWhitespaceForm):
class ServiceReplyToEmailForm(StripWhitespaceForm): class ServiceReplyToEmailForm(StripWhitespaceForm):
email_address = email_address(label='Reply-to email address', gov_user=False) email_address = email_address(label='Reply-to email address', gov_user=False)
is_default = BooleanField("Make this email address the default") is_default = govukCheckboxField("Make this email address the default")
class ServiceSmsSenderForm(StripWhitespaceForm): class ServiceSmsSenderForm(StripWhitespaceForm):
@@ -1353,11 +1353,11 @@ class ServiceSmsSenderForm(StripWhitespaceForm):
DoesNotStartWithDoubleZero(), DoesNotStartWithDoubleZero(),
] ]
) )
is_default = BooleanField("Make this text message sender the default") is_default = govukCheckboxField("Make this text message sender the default")
class ServiceEditInboundNumberForm(StripWhitespaceForm): class ServiceEditInboundNumberForm(StripWhitespaceForm):
is_default = BooleanField("Make this text message sender the default") is_default = govukCheckboxField("Make this text message sender the default")
class ServiceLetterContactBlockForm(StripWhitespaceForm): class ServiceLetterContactBlockForm(StripWhitespaceForm):
@@ -1367,7 +1367,7 @@ class ServiceLetterContactBlockForm(StripWhitespaceForm):
NoCommasInPlaceHolders() NoCommasInPlaceHolders()
] ]
) )
is_default = BooleanField("Set as your default address") is_default = govukCheckboxField("Set as your default address")
def validate_letter_contact_block(self, field): def validate_letter_contact_block(self, field):
line_count = field.data.strip().count('\n') line_count = field.data.strip().count('\n')
@@ -1533,7 +1533,7 @@ class GuestList(StripWhitespaceForm):
class DateFilterForm(StripWhitespaceForm): class DateFilterForm(StripWhitespaceForm):
start_date = DateField("Start Date", [validators.optional()]) start_date = DateField("Start Date", [validators.optional()])
end_date = DateField("End Date", [validators.optional()]) end_date = DateField("End Date", [validators.optional()])
include_from_test_key = BooleanField("Include test keys", default="checked", false_values={"N"}) include_from_test_key = govukCheckboxField("Include test keys")
class RequiredDateFilterForm(StripWhitespaceForm): class RequiredDateFilterForm(StripWhitespaceForm):

View File

@@ -168,9 +168,11 @@ def platform_admin_services():
# Default to True if the user hasnt done any filtering, # Default to True if the user hasnt done any filtering,
# otherwise respect their choice # otherwise respect their choice
form.include_from_test_key.data = True form.include_from_test_key.data = True
include_from_test_key = form.include_from_test_key.data
api_args = {'detailed': True, api_args = {'detailed': True,
'only_active': False, # specifically DO get inactive services 'only_active': False, # specifically DO get inactive services
'include_from_test_key': form.include_from_test_key.data, 'include_from_test_key': include_from_test_key,
} }
if form.start_date.data: if form.start_date.data:
@@ -184,7 +186,7 @@ def platform_admin_services():
return render_template( return render_template(
'views/platform-admin/services.html', 'views/platform-admin/services.html',
include_from_test_key=form.include_from_test_key.data, include_from_test_key=include_from_test_key,
form=form, form=form,
services=list(format_stats_by_service(services)), services=list(format_stats_by_service(services)),
page_title='{} services'.format( page_title='{} services'.format(

View File

@@ -70,8 +70,7 @@
{% call form_wrapper(method="get") %} {% call form_wrapper(method="get") %}
{{ textbox(form.start_date, hint="Enter start date in format YYYY-MM-DD") }} {{ textbox(form.start_date, hint="Enter start date in format YYYY-MM-DD") }}
{{ textbox(form.end_date, hint="Enter end date in format YYYY-MM-DD") }} {{ textbox(form.end_date, hint="Enter end date in format YYYY-MM-DD") }}
{{ checkbox(form.include_from_test_key) }} {{ form.include_from_test_key }}
</br>
{{ govukButton({ "text": "Filter" }) }} {{ govukButton({ "text": "Filter" }) }}
{% endcall %} {% endcall %}
{% endset %} {% endset %}

View File

@@ -55,9 +55,7 @@
hint='This should be a shared inbox managed by your team, not your own email address' hint='This should be a shared inbox managed by your team, not your own email address'
) }} ) }}
{% if not first_email_address and not existing_is_default %} {% if not first_email_address and not existing_is_default %}
<div class="form-group"> {{ form.is_default }}
{{ checkbox(form.is_default) }}
</div>
{% endif %} {% endif %}
{{ page_footer('Try again') }} {{ page_footer('Try again') }}
{% endcall %} {% endcall %}

View File

@@ -24,9 +24,7 @@
safe_error_message=True safe_error_message=True
) }} ) }}
{% if not first_email_address %} {% if not first_email_address %}
<div class="form-group"> {{ form.is_default }}
{{ checkbox(form.is_default) }}
</div>
{% endif %} {% endif %}
{{ page_footer('Add') }} {{ page_footer('Add') }}
{% endcall %} {% endcall %}

View File

@@ -29,9 +29,7 @@
</p> </p>
{{ page_footer('Save') }} {{ page_footer('Save') }}
{% else %} {% else %}
<div class="form-group"> {{ form.is_default }}
{{ checkbox(form.is_default) }}
</div>
{{ page_footer( {{ page_footer(
'Save', 'Save',
delete_link=url_for('.service_confirm_delete_email_reply_to', service_id=current_service.id, reply_to_email_id=reply_to_email_address_id), delete_link=url_for('.service_confirm_delete_email_reply_to', service_id=current_service.id, reply_to_email_id=reply_to_email_address_id),

View File

@@ -27,9 +27,7 @@
highlight_placeholders=True highlight_placeholders=True
) }} ) }}
{% if not first_contact_block %} {% if not first_contact_block %}
<div class="form-group"> {{ form.is_default }}
{{ checkbox(form.is_default) }}
</div>
{% endif %} {% endif %}
{{ page_footer('Add') }} {{ page_footer('Add') }}
{% endcall %} {% endcall %}

View File

@@ -31,9 +31,7 @@
This is currently your default address for {{ current_service.name }}. This is currently your default address for {{ current_service.name }}.
</p> </p>
{% else %} {% else %}
<div class="form-group"> {{ form.is_default }}
{{ checkbox(form.is_default) }}
</div>
{% endif %} {% endif %}
{{ page_footer( {{ page_footer(

View File

@@ -23,9 +23,7 @@
hint='Up to 11 characters, letters, numbers and spaces only' hint='Up to 11 characters, letters, numbers and spaces only'
) }} ) }}
{% if not first_sms_sender %} {% if not first_sms_sender %}
<div class="form-group"> {{ form.is_default }}
{{ checkbox(form.is_default) }}
</div>
{% endif %} {% endif %}
{{ page_footer('Save') }} {{ page_footer('Save') }}
{% endcall %} {% endcall %}

View File

@@ -35,9 +35,7 @@
</p> </p>
{{ page_footer('Save') }} {{ page_footer('Save') }}
{% else %} {% else %}
<div class="form-group"> {{ form.is_default }}
{{ checkbox(form.is_default) }}
</div>
{% if inbound_number %} {% if inbound_number %}
{{ page_footer('Save') }} {{ page_footer('Save') }}
{% else %} {% else %}