mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-02 17:48:50 -04:00
Allow updates to SMS prefixing setting
We’re extracting this from being determined based on what the sender name is to its own setting. This commit will let users set it independently. Until the explicitly set it, it will still be determined based on whether their default sender name matches the default for the platform.
This commit is contained in:
@@ -721,6 +721,16 @@ class InternationalSMSForm(Form):
|
||||
)
|
||||
|
||||
|
||||
class SMSPrefixForm(Form):
|
||||
enabled = RadioField(
|
||||
'Start all text messages with service name',
|
||||
choices=[
|
||||
('on', 'On'),
|
||||
('off', 'Off'),
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
def get_placeholder_form_instance(
|
||||
placeholder_name,
|
||||
dict_to_populate_from,
|
||||
|
||||
@@ -38,6 +38,7 @@ from app.main.forms import (
|
||||
OrganisationTypeForm,
|
||||
FreeSMSAllowance,
|
||||
ServiceEditInboundNumberForm,
|
||||
SMSPrefixForm,
|
||||
)
|
||||
from app import user_api_client, current_service, organisations_client, inbound_number_client
|
||||
from notifications_utils.formatters import formatted_list
|
||||
@@ -103,7 +104,8 @@ def service_settings(service_id):
|
||||
default_letter_contact_block=default_letter_contact_block,
|
||||
letter_contact_details_count=letter_contact_details_count,
|
||||
default_sms_sender=default_sms_sender,
|
||||
sms_sender_count=sms_sender_count
|
||||
sms_sender_count=sms_sender_count,
|
||||
prefix_sms_with_service_name=current_service['prefix_sms_with_service_name'],
|
||||
)
|
||||
|
||||
|
||||
@@ -486,6 +488,28 @@ def service_set_sms(service_id):
|
||||
)
|
||||
|
||||
|
||||
@main.route("/services/<service_id>/service-settings/sms-prefix", methods=['GET', 'POST'])
|
||||
@login_required
|
||||
@user_has_permissions('manage_settings', admin_override=True)
|
||||
def service_set_sms_prefix(service_id):
|
||||
|
||||
form = SMSPrefixForm(enabled=(
|
||||
'on' if current_service['prefix_sms_with_service_name'] else 'off'
|
||||
))
|
||||
|
||||
if form.validate_on_submit():
|
||||
service_api_client.update_service(
|
||||
current_service['id'],
|
||||
prefix_sms_with_service_name=(form.enabled.data == 'on')
|
||||
)
|
||||
return redirect(url_for('.service_settings', service_id=service_id))
|
||||
|
||||
return render_template(
|
||||
'views/service-settings/sms-prefix.html',
|
||||
form=form
|
||||
)
|
||||
|
||||
|
||||
@main.route("/services/<service_id>/service-settings/set-international-sms", methods=['GET', 'POST'])
|
||||
@login_required
|
||||
@user_has_permissions('manage_settings', admin_override=True)
|
||||
|
||||
@@ -107,6 +107,7 @@ class ServiceAPIClient(NotifyAdminAPIClient):
|
||||
'permissions',
|
||||
'organisation_type',
|
||||
'free_sms_fragment_limit',
|
||||
'prefix_sms_with_service_name',
|
||||
}
|
||||
if disallowed_attributes:
|
||||
raise TypeError('Not allowed to update service attributes: {}'.format(
|
||||
|
||||
@@ -92,6 +92,12 @@
|
||||
{{ edit_field('Manage' if sms_sender_count else 'Change', url_for('.service_sms_senders', service_id=current_service.id)) }}
|
||||
{% endcall %}
|
||||
|
||||
{% call row() %}
|
||||
{{ text_field('Start all text messages with service name') }}
|
||||
{{ boolean_field(prefix_sms_with_service_name) }}
|
||||
{{ edit_field('Change', url_for('.service_set_sms_prefix', service_id=current_service.id)) }}
|
||||
{% endcall %}
|
||||
|
||||
{% call row() %}
|
||||
{{ text_field('International text messages') }}
|
||||
{{ boolean_field('international_sms' in current_service.permissions) }}
|
||||
|
||||
24
app/templates/views/service-settings/sms-prefix.html
Normal file
24
app/templates/views/service-settings/sms-prefix.html
Normal file
@@ -0,0 +1,24 @@
|
||||
{% extends "withnav_template.html" %}
|
||||
{% from "components/radios.html" import radios %}
|
||||
{% from "components/page-footer.html" import page_footer %}
|
||||
|
||||
{% block service_page_title %}
|
||||
Start all text messages with service name
|
||||
{% endblock %}
|
||||
|
||||
{% block maincolumn_content %}
|
||||
|
||||
<h1 class="heading-large">Start all text messages with service name</h1>
|
||||
<p>
|
||||
Your service name is {{ current_service.name}}.
|
||||
</p>
|
||||
<form method="post">
|
||||
{{ radios(form.enabled) }}
|
||||
{{ page_footer(
|
||||
button_text="Save",
|
||||
back_link=url_for('.service_settings', service_id=current_service.id),
|
||||
back_link_text='Back to settings'
|
||||
) }}
|
||||
</form>
|
||||
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user