mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-10 10:03:21 -04:00
Refactor use ServiceOnOffForm
We no longer need a custom form object here – ServiceOnOffForm does the same job of turning strings to booleans and back again.
This commit is contained in:
@@ -1719,16 +1719,6 @@ class ServiceDeliveryStatusCallbackForm(CallbackForm):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class InternationalSMSForm(StripWhitespaceForm):
|
|
||||||
enabled = RadioField(
|
|
||||||
'Send text messages to international phone numbers',
|
|
||||||
choices=[
|
|
||||||
('on', 'On'),
|
|
||||||
('off', 'Off'),
|
|
||||||
],
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class SMSPrefixForm(StripWhitespaceForm):
|
class SMSPrefixForm(StripWhitespaceForm):
|
||||||
enabled = RadioField(
|
enabled = RadioField(
|
||||||
'',
|
'',
|
||||||
|
|||||||
@@ -35,7 +35,6 @@ from app.main.forms import (
|
|||||||
ConfirmPasswordForm,
|
ConfirmPasswordForm,
|
||||||
EstimateUsageForm,
|
EstimateUsageForm,
|
||||||
FreeSMSAllowance,
|
FreeSMSAllowance,
|
||||||
InternationalSMSForm,
|
|
||||||
LinkOrganisationsForm,
|
LinkOrganisationsForm,
|
||||||
PreviewBranding,
|
PreviewBranding,
|
||||||
RenameServiceForm,
|
RenameServiceForm,
|
||||||
@@ -648,13 +647,14 @@ def service_set_sms_prefix(service_id):
|
|||||||
@main.route("/services/<uuid:service_id>/service-settings/set-international-sms", methods=['GET', 'POST'])
|
@main.route("/services/<uuid:service_id>/service-settings/set-international-sms", methods=['GET', 'POST'])
|
||||||
@user_has_permissions('manage_service')
|
@user_has_permissions('manage_service')
|
||||||
def service_set_international_sms(service_id):
|
def service_set_international_sms(service_id):
|
||||||
form = InternationalSMSForm(
|
form = ServiceOnOffSettingForm(
|
||||||
enabled='on' if current_service.has_permission('international_sms') else 'off'
|
'Send text messages to international phone numbers',
|
||||||
|
enabled=current_service.has_permission('international_sms'),
|
||||||
)
|
)
|
||||||
if form.validate_on_submit():
|
if form.validate_on_submit():
|
||||||
current_service.force_permission(
|
current_service.force_permission(
|
||||||
'international_sms',
|
'international_sms',
|
||||||
on=(form.enabled.data == 'on'),
|
on=form.enabled.data,
|
||||||
)
|
)
|
||||||
return redirect(
|
return redirect(
|
||||||
url_for(".service_settings", service_id=service_id)
|
url_for(".service_settings", service_id=service_id)
|
||||||
|
|||||||
@@ -3788,8 +3788,8 @@ def test_broadcast_service_cant_post_to_set_other_channels_endpoint(
|
|||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize('permissions, expected_checked', [
|
@pytest.mark.parametrize('permissions, expected_checked', [
|
||||||
(['international_sms'], 'on'),
|
(['international_sms'], 'True'),
|
||||||
([''], 'off'),
|
([''], 'False'),
|
||||||
])
|
])
|
||||||
def test_show_international_sms_as_radio_button(
|
def test_show_international_sms_as_radio_button(
|
||||||
client_request,
|
client_request,
|
||||||
@@ -3812,8 +3812,8 @@ def test_show_international_sms_as_radio_button(
|
|||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize('post_value, international_sms_permission_expected_in_api_call', [
|
@pytest.mark.parametrize('post_value, international_sms_permission_expected_in_api_call', [
|
||||||
('on', True),
|
('True', True),
|
||||||
('off', False),
|
('False', False),
|
||||||
])
|
])
|
||||||
def test_switch_service_enable_international_sms(
|
def test_switch_service_enable_international_sms(
|
||||||
client_request,
|
client_request,
|
||||||
|
|||||||
Reference in New Issue
Block a user