mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-09 02:43:12 -04:00
A lot of pages in the admin app are now generated entirely from Redis, without touching the API. The one remaining API call that a lot of pages make, when the user is platform admin or a member of an organisation, is to get the name of the current service’s organisation. This commit adds some code to start caching that as well, which should speed up page load times for when we’re clicking around the admin app (it’s typically 100ms just to get the organisation, and more than that when the API is under load). This means changing the service model to get the organisation from the API by ID, not by service ID. Otherwise it would be very hard to clear the cache if the name of the organisation ever changed. We can’t cache the whole organisation because it has a `count_of_live_services` field which can change at any time, without an update being made.
404 lines
15 KiB
HTML
404 lines
15 KiB
HTML
{% extends "withnav_template.html" %}
|
|
{% from "components/banner.html" import banner_wrapper %}
|
|
{% from "components/table.html" import mapping_table, row, settings_row, text_field, optional_text_field, edit_field, field, boolean_field with context %}
|
|
|
|
{% block service_page_title %}
|
|
Settings
|
|
{% endblock %}
|
|
|
|
{% block maincolumn_content %}
|
|
|
|
<h1 class="heading-medium">Settings</h1>
|
|
|
|
<div class="bottom-gutter-3-2 settings-table body-copy-table">
|
|
|
|
{% call mapping_table(
|
|
caption='General',
|
|
field_headings=['Label', 'Value', 'Action'],
|
|
field_headings_visible=False,
|
|
caption_visible=False
|
|
) %}
|
|
|
|
{% call row() %}
|
|
{{ text_field('Service name') }}
|
|
{{ text_field(current_service.name) }}
|
|
{{ edit_field(
|
|
'Change',
|
|
url_for('.service_name_change', service_id=current_service.id),
|
|
permissions=['manage_service']
|
|
)
|
|
}}
|
|
{% endcall %}
|
|
|
|
{% call row() %}
|
|
{{ text_field('Sign-in method') }}
|
|
{{ text_field(
|
|
'Email link or text message code'
|
|
if 'email_auth' in current_service.permissions
|
|
else 'Text message code'
|
|
) }}
|
|
{{ edit_field(
|
|
'Change',
|
|
url_for('.service_set_auth_type',
|
|
service_id=current_service.id),
|
|
permissions=['manage_service']
|
|
)
|
|
}}
|
|
{% endcall %}
|
|
{% endcall %}
|
|
|
|
{% call mapping_table(
|
|
caption='Email settings',
|
|
field_headings=['Label', 'Value', 'Action'],
|
|
field_headings_visible=False,
|
|
caption_visible=True
|
|
) %}
|
|
|
|
{% call row() %}
|
|
{{ text_field('Send emails') }}
|
|
{{ boolean_field('email' in current_service.permissions) }}
|
|
{{ edit_field(
|
|
'Change',
|
|
url_for(
|
|
'.service_set_channel',
|
|
channel='email',
|
|
service_id=current_service.id
|
|
),
|
|
permissions=['manage_service']
|
|
)}}
|
|
{% endcall %}
|
|
|
|
{% call settings_row(if_has_permission='email') %}
|
|
{{ text_field('Reply-to email addresses') }}
|
|
{% call field(status='default' if current_service.count_email_reply_to_addresses == 0 else '') %}
|
|
{{ current_service.default_email_reply_to_address or 'Not set' }}
|
|
{% if current_service.count_email_reply_to_addresses > 1 %}
|
|
<div class="hint">
|
|
{{ '…and %d more' | format(current_service.count_email_reply_to_addresses - 1) }}
|
|
</div>
|
|
{% endif %}
|
|
{% endcall %}
|
|
{{ edit_field(
|
|
'Manage',
|
|
url_for('.service_email_reply_to',
|
|
service_id=current_service.id),
|
|
permissions=['manage_service','manage_api_keys']
|
|
)
|
|
}}
|
|
{% endcall %}
|
|
|
|
{% call settings_row(if_has_permission='email') %}
|
|
{{ text_field('Email branding') }}
|
|
{{ text_field(current_service.email_branding_name) }}
|
|
{{ edit_field(
|
|
'Change',
|
|
url_for('.branding_request', service_id=current_service.id, branding_type="email"),
|
|
permissions=['manage_service'],
|
|
)}}
|
|
{% endcall %}
|
|
|
|
{% call settings_row(if_has_permission='email') %}
|
|
{{ text_field('Send files by email') }}
|
|
{{ text_field(current_service.contact_link if current_service.contact_link else "Not set up", truncate=true) }}
|
|
{{ edit_field(
|
|
'Manage',
|
|
url_for('.send_files_by_email_contact_details', service_id=current_service.id),
|
|
permissions=['manage_service'],
|
|
)}}
|
|
{% endcall %}
|
|
|
|
{% endcall %}
|
|
|
|
{% call mapping_table(
|
|
caption='Text message settings',
|
|
field_headings=['Label', 'Value', 'Action'],
|
|
field_headings_visible=False,
|
|
caption_visible=True
|
|
) %}
|
|
|
|
{% call row() %}
|
|
{{ text_field('Send text messages') }}
|
|
{{ boolean_field('sms' in current_service.permissions) }}
|
|
{{ edit_field(
|
|
'Change',
|
|
url_for(
|
|
'.service_set_channel',
|
|
service_id=current_service.id,
|
|
channel='sms'
|
|
),
|
|
permissions=['manage_service']
|
|
)}}
|
|
{% endcall %}
|
|
|
|
{% call settings_row(if_has_permission='sms') %}
|
|
{{ text_field('Text message senders') }}
|
|
{% call field(status='default' if current_service.default_sms_sender == "None" else '') %}
|
|
{{ current_service.default_sms_sender | nl2br if current_service.default_sms_sender else 'None'}}
|
|
{% if current_service.count_sms_senders > 1 %}
|
|
<div class="hint">
|
|
{{ '…and %d more' | format(current_service.count_sms_senders - 1) }}
|
|
</div>
|
|
{% endif %}
|
|
{% endcall %}
|
|
{{ edit_field(
|
|
'Manage',
|
|
url_for('.service_sms_senders',
|
|
service_id=current_service.id),
|
|
permissions=['manage_service','manage_api_keys']
|
|
)
|
|
}}
|
|
{% endcall %}
|
|
|
|
{% call settings_row(if_has_permission='sms') %}
|
|
{{ text_field('Start text messages with service name') }}
|
|
{{ boolean_field(current_service.prefix_sms) }}
|
|
{{ edit_field(
|
|
'Change',
|
|
url_for('.service_set_sms_prefix',
|
|
service_id=current_service.id),
|
|
permissions=['manage_service']
|
|
)
|
|
}}
|
|
{% endcall %}
|
|
|
|
{% call settings_row(if_has_permission='sms') %}
|
|
{{ text_field('Send international text messages') }}
|
|
{{ boolean_field('international_sms' in current_service.permissions) }}
|
|
{{ edit_field(
|
|
'Change',
|
|
url_for('.service_set_international_sms',
|
|
service_id=current_service.id),
|
|
permissions=['manage_service']
|
|
)
|
|
}}
|
|
{% endcall %}
|
|
|
|
{% call settings_row(if_has_permission='sms') %}
|
|
{{ text_field('Receive text messages') }}
|
|
{{ boolean_field('inbound_sms' in current_service.permissions) }}
|
|
{{ edit_field(
|
|
'Change',
|
|
url_for('.service_set_inbound_sms',
|
|
service_id=current_service.id),
|
|
permissions=['manage_service']
|
|
)
|
|
}}
|
|
{% endcall %}
|
|
|
|
{% endcall %}
|
|
|
|
{% call mapping_table(
|
|
caption='Letter settings',
|
|
field_headings=['Label', 'Value', 'Action'],
|
|
field_headings_visible=False,
|
|
caption_visible=True
|
|
) %}
|
|
|
|
{% call row() %}
|
|
{{ text_field('Send letters') }}
|
|
{{ boolean_field('letter' in current_service.permissions) }}
|
|
{{ edit_field(
|
|
'Change',
|
|
url_for(
|
|
'.service_set_channel',
|
|
channel='letter',
|
|
service_id=current_service.id
|
|
),
|
|
permissions=['manage_service']
|
|
)}}
|
|
{% endcall %}
|
|
|
|
{% call settings_row(if_has_permission='letter') %}
|
|
{{ text_field('Sender addresses') }}
|
|
{% call field(status='' if current_service.count_letter_contact_details else 'default') %}
|
|
{% if current_service.default_letter_contact_block %}
|
|
{{ current_service.default_letter_contact_block_html }}
|
|
{% elif current_service.count_letter_contact_details %}
|
|
Blank
|
|
{% else %}
|
|
Not set
|
|
{% endif %}
|
|
{% if current_service.count_letter_contact_details > 1 %}
|
|
<div class="hint">
|
|
{{ '…and %d more' | format(current_service.count_letter_contact_details - 1) }}
|
|
</div>
|
|
{% endif %}
|
|
{% endcall %}
|
|
{{ edit_field(
|
|
'Manage',
|
|
url_for('.service_letter_contact_details',
|
|
service_id=current_service.id),
|
|
permissions=['manage_service','manage_api_keys']
|
|
)
|
|
}}
|
|
{% endcall %}
|
|
|
|
{% call settings_row(if_has_permission='letter') %}
|
|
{{ text_field('Letter branding') }}
|
|
{{ optional_text_field(current_service.letter_branding.name) }}
|
|
{{ edit_field(
|
|
'Change',
|
|
url_for('.branding_request', service_id=current_service.id, branding_type="letter"),
|
|
permissions=['manage_service']
|
|
)}}
|
|
{% endcall %}
|
|
|
|
{% endcall %}
|
|
</div>
|
|
|
|
{% if current_service.trial_mode %}
|
|
<h2 class="heading-medium top-gutter-0">Your service is in trial mode</h2>
|
|
|
|
<p>You can only:</p>
|
|
|
|
<ul class='list list-bullet'>
|
|
<li>send {{ current_service.message_limit }} text messages and emails per day</li>
|
|
<li>send messages to yourself and other people in your team</li>
|
|
<li>create letter templates, but not send them</li>
|
|
</ul>
|
|
|
|
<p>
|
|
{% if current_user.has_permissions('manage_service') %}
|
|
To remove these restrictions, you can send us a
|
|
<a class="govuk-link govuk-link--no-visited-state" href="{{ url_for('.request_to_go_live', service_id=current_service.id) }}">request to go live</a>.
|
|
{% else %}
|
|
Your service manager can ask to have these restrictions removed.
|
|
{% endif %}
|
|
</p>
|
|
|
|
{% else %}
|
|
<h2 class="heading-medium top-gutter-0">Your service is live</h2>
|
|
|
|
<p>
|
|
You can send up to
|
|
{{ "{:,}".format(current_service.message_limit) }} messages
|
|
per day.
|
|
</p>
|
|
<p>
|
|
Problems or comments?
|
|
<a class="govuk-link govuk-link--no-visited-state" href="{{ url_for('main.support') }}">Give feedback</a>.
|
|
</p>
|
|
|
|
{% endif %}
|
|
|
|
{% if current_user.platform_admin %}
|
|
|
|
<div class="settings-table body-copy-table top-gutter-4-3">
|
|
|
|
<h2 class="heading-medium">Platform admin settings</h2>
|
|
|
|
{% call mapping_table(
|
|
caption='Settings',
|
|
field_headings=['Label', 'Value', 'Action'],
|
|
field_headings_visible=False,
|
|
caption_visible=False
|
|
) %}
|
|
|
|
{% call row() %}
|
|
{{ text_field('Live')}}
|
|
{% if current_service.trial_mode and not current_service.organisation %}
|
|
{{ text_field('No (organisation must be set first)') }}
|
|
{{ text_field('') }}
|
|
{% else %}
|
|
{{ boolean_field(not current_service.trial_mode) }}
|
|
{{ edit_field('Change', url_for('.service_switch_live', service_id=current_service.id)) }}
|
|
{% endif %}
|
|
{% endcall %}
|
|
|
|
{% call row() %}
|
|
{{ text_field('Count in list of live services')}}
|
|
{{ text_field('Yes' if current_service.count_as_live else 'No') }}
|
|
{{ edit_field('Change', url_for('.service_switch_count_as_live', service_id=current_service.id)) }}
|
|
{% endcall %}
|
|
|
|
{% call row() %}
|
|
{{ text_field('Organisation')}}
|
|
{% call field() %}
|
|
{% if current_service.organisation_id %}
|
|
<a class="govuk-link govuk-link--no-visited-state" href="{{ url_for('main.organisation_dashboard', org_id=current_service.organisation_id) }}">
|
|
{{ current_service.organisation_name }}
|
|
</a>
|
|
{% else %}
|
|
<span class="table-field-status-default">Not set</span>
|
|
{% endif %}
|
|
{% if current_service.organisation_type %}
|
|
<div class="hint">
|
|
{{ current_service.organisation_type_label }}
|
|
</div>
|
|
{% endif %}
|
|
{% endcall %}
|
|
{{ edit_field('Change', url_for('.link_service_to_organisation', service_id=current_service.id)) }}
|
|
{% endcall %}
|
|
|
|
{% call row() %}
|
|
{{ text_field('Free text message allowance')}}
|
|
{{ text_field('{:,}'.format(current_service.free_sms_fragment_limit)) }}
|
|
{{ edit_field('Change', url_for('.set_free_sms_allowance', service_id=current_service.id)) }}
|
|
{% endcall %}
|
|
{% call row() %}
|
|
{{ text_field('Email branding' )}}
|
|
{{ text_field(current_service.email_branding_name) }}
|
|
{{ edit_field('Change', url_for('.service_set_email_branding', service_id=current_service.id)) }}
|
|
{% endcall %}
|
|
{% call row() %}
|
|
{{ text_field('Letter branding')}}
|
|
{{ optional_text_field(current_service.letter_branding.name) }}
|
|
{{ edit_field('Change', url_for('.service_set_letter_branding', service_id=current_service.id)) }}
|
|
{% endcall %}
|
|
{% call row() %}
|
|
{{ text_field('Data retention')}}
|
|
{% call field() %}
|
|
{{ current_service.data_retention | join(', ', attribute='notification_type') }}
|
|
{% endcall %}
|
|
{{ edit_field('Change', url_for('.data_retention', service_id=current_service.id)) }}
|
|
{% endcall %}
|
|
|
|
{% for permission in service_permissions %}
|
|
{% if not service_permissions[permission].requires or current_service.has_permission(service_permissions[permission].requires) %}
|
|
{% call row() %}
|
|
{{ text_field(service_permissions[permission].title)}}
|
|
{{ boolean_field(current_service.has_permission(permission)) }}
|
|
{{ edit_field('Change', url_for(service_permissions[permission].endpoint or '.service_set_permission', service_id=current_service.id, permission=permission if not service_permissions[permission].endpoint else None)) }}
|
|
{% endcall %}
|
|
{% endif %}
|
|
{% endfor %}
|
|
|
|
{% endcall %}
|
|
|
|
</div>
|
|
|
|
{% endif %}
|
|
|
|
{% if current_service.active and (current_service.trial_mode or current_user.platform_admin) %}
|
|
<p class="top-gutter-1-2">
|
|
<span class="page-footer-delete-link page-footer-delete-link-without-button">
|
|
<a class="govuk-link govuk-link--destructive" href="{{ url_for('.archive_service', service_id=current_service.id) }}">
|
|
Delete this service
|
|
</a>
|
|
</span>
|
|
{% if current_user.platform_admin %}
|
|
<span class="page-footer-delete-link">
|
|
<a href="{{ url_for('.suspend_service', service_id=current_service.id) }}" class="govuk-link govuk-link--destructive page-footer-delete-link">
|
|
Suspend service
|
|
</a>
|
|
</span>
|
|
{% endif %}
|
|
</p>
|
|
{% endif %}
|
|
{% if (not current_service.active) and current_user.platform_admin %}
|
|
<p>
|
|
<div class="hint bottom-gutter-1-2">
|
|
Service suspended
|
|
</div>
|
|
<span class="page-footer-delete-link page-footer-delete-link-without-button">
|
|
<a class="govuk-link govuk-link--destructive" href="{{ url_for('.resume_service', service_id=current_service.id) }}">
|
|
Resume service
|
|
</a>
|
|
</span>
|
|
</p>
|
|
{% endif %}
|
|
|
|
|
|
{% endblock %}
|
|
}
|