diff --git a/app/assets/stylesheets/components/table.scss b/app/assets/stylesheets/components/table.scss index 14ae48f10..563323692 100644 --- a/app/assets/stylesheets/components/table.scss +++ b/app/assets/stylesheets/components/table.scss @@ -156,6 +156,18 @@ } + td.table-field-wrap-text { + + div { + white-space: normal; + } + + ul li { + margin-bottom: 5px; + } + + } + .table-heading { margin-bottom: 20px; } diff --git a/app/main/forms.py b/app/main/forms.py index e2943dfbe..be52c3609 100644 --- a/app/main/forms.py +++ b/app/main/forms.py @@ -1706,6 +1706,10 @@ class ServiceEditInboundNumberForm(StripWhitespaceForm): is_default = GovukCheckboxField("Make this text message sender the default") +class EditServiceNotesForm(StripWhitespaceForm): + notes = TextAreaField(validators=[]) + + class ServiceLetterContactBlockForm(StripWhitespaceForm): letter_contact_block = TextAreaField( validators=[ diff --git a/app/main/views/service_settings.py b/app/main/views/service_settings.py index b11345304..1ff6fbe9f 100644 --- a/app/main/views/service_settings.py +++ b/app/main/views/service_settings.py @@ -34,6 +34,7 @@ from app.main import main from app.main.forms import ( BrandingOptions, ConfirmPasswordForm, + EditServiceNotesForm, EstimateUsageForm, FreeSMSAllowance, LinkOrganisationsForm, @@ -1188,6 +1189,27 @@ def edit_data_retention(service_id, data_retention_id): ) +@main.route("/services//notes", methods=['GET', 'POST']) +@user_has_permissions('manage_service') +def edit_service_notes(service_id): + form = EditServiceNotesForm(notes=current_service.notes) + + if form.validate_on_submit(): + + if form.notes.data == current_service.notes: + return redirect(url_for('.service_settings', service_id=service_id)) + + current_service.update( + notes=form.notes.data + ) + return redirect(url_for('.service_settings', service_id=service_id)) + + return render_template( + 'views/service-settings/edit-service-notes.html', + form=form, + ) + + def get_branding_as_value_and_label(email_branding): return [ (branding['id'], branding['name']) diff --git a/app/models/service.py b/app/models/service.py index 3f699e54d..e3a23fc54 100644 --- a/app/models/service.py +++ b/app/models/service.py @@ -37,6 +37,7 @@ class Service(JSONModel): 'message_limit', 'rate_limit', 'name', + 'notes', 'prefix_sms', 'research_mode', 'service_callback_api', diff --git a/app/navigation.py b/app/navigation.py index 22f5b7924..3537fb7d3 100644 --- a/app/navigation.py +++ b/app/navigation.py @@ -190,6 +190,7 @@ class HeaderNavigation(Navigation): 'edit_organisation_name', 'edit_organisation_type', 'edit_provider', + 'edit_service_notes', 'edit_service_template', 'edit_template_postage', 'edit_user_org_permissions', @@ -582,6 +583,7 @@ class MainNavigation(Navigation): 'edit_organisation_name', 'edit_organisation_type', 'edit_provider', + 'edit_service_notes', 'edit_sms_provider_ratio', 'edit_user_org_permissions', 'email_branding', @@ -835,6 +837,7 @@ class CaseworkNavigation(Navigation): 'edit_organisation_name', 'edit_organisation_type', 'edit_provider', + 'edit_service_notes', 'edit_sms_provider_ratio', 'edit_service_template', 'edit_template_postage', @@ -1158,6 +1161,7 @@ class OrgNavigation(Navigation): 'download_notifications_csv', 'edit_data_retention', 'edit_provider', + 'edit_service_notes', 'edit_service_template', 'edit_sms_provider_ratio', 'edit_template_postage', diff --git a/app/notify_client/service_api_client.py b/app/notify_client/service_api_client.py index ac068dd8f..a3dfbcc40 100644 --- a/app/notify_client/service_api_client.py +++ b/app/notify_client/service_api_client.py @@ -109,12 +109,12 @@ class ServiceAPIClient(NotifyAdminAPIClient): 'go_live_user', 'go_live_at', 'rate_limit', + 'notes', } if disallowed_attributes: raise TypeError('Not allowed to update service attributes: {}'.format( ", ".join(disallowed_attributes) )) - endpoint = "/service/{0}".format(service_id) return self.post(endpoint, data) diff --git a/app/templates/components/table.html b/app/templates/components/table.html index 72b6cdc3b..cfd029ee8 100644 --- a/app/templates/components/table.html +++ b/app/templates/components/table.html @@ -63,12 +63,13 @@ {% endif %} {%- endmacro %} -{% macro field(align='left', status='', border=True, colspan=None) -%} +{% macro field(align='left', status='', border=True, colspan=None, wrap=False) -%} {% set field_alignment = 'table-field-right-aligned' if align == 'right' else 'table-field-left-aligned' %} {% set border = '' if border else 'table-field-noborder' %} + {% set wrap = 'table-field-wrap-text' if wrap else '' %} - +
{{ caller() }}
{%- endmacro %} @@ -85,8 +86,8 @@ {%- endmacro %} -{% macro text_field(text, status='', truncate=false) -%} - {% call field(status=status) %} +{% macro text_field(text, status='', truncate=false, wrap=False) -%} + {% call field(status=status, wrap=wrap) %} {% if text is iterable and text is not string %}