Merge pull request #2423 from alphagov/make-service-model-wrap-more-things

Move more things from the view layer to the service model
This commit is contained in:
Chris Hill-Scott
2018-10-31 09:39:19 +00:00
committed by GitHub
59 changed files with 527 additions and 434 deletions

View File

@@ -7,7 +7,7 @@
</h1>
<p>
You can only send {{ current_service.message_limit }} messages per day
{%- if current_service.restricted %}
{%- if current_service.trial_mode %}
in <a href="{{ url_for('.using_notify')}}#trial-mode">trial mode</a>
{%- endif -%}
.

View File

@@ -15,7 +15,7 @@
<div class="dashboard">
<h1 class="visuallyhidden">Dashboard</h1>
{% if current_user.has_permissions('manage_templates') and not templates %}
{% if current_user.has_permissions('manage_templates') and not current_service.templates %}
{% include 'views/dashboard/write-first-messages.html' %}
{% endif %}

View File

@@ -17,7 +17,7 @@
{% for service in organisation_services %}
<li class="browse-list-item">
{% if service.has_permission_to_view %}
<a href="{{ url_for('main.service_dashboard', service_id=service['id']) }}" class="browse-list-link">{{ service['name'] }}</a>
<a href="{{ url_for('main.service_dashboard', service_id=service.id) }}" class="browse-list-link">{{ service['name'] }}</a>
{% else %}
{{ service['name'] }}
{% endif %}

View File

@@ -81,17 +81,16 @@
{% call settings_row(if_has_permission='email') %}
{{ text_field('Email reply-to addresses') }}
{% call field(status='default' if default_reply_to_email_address == "Not set" else '') %}
{{ default_reply_to_email_address }}
{% if reply_to_email_address_count > 1 %}
{% call field(status='default' if default_reply_to_email_address == None 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(reply_to_email_address_count - 1) }}
{{ '…and %d more' | format(current_service.count_email_reply_to_addresses - 1) }}
</div>
{% endif %}
{% endcall %}
{{ edit_field(
'Manage' if reply_to_email_address_count else 'Change',
'Manage' if current_service.count_email_reply_to_addresses else 'Change',
url_for('.service_email_reply_to',
service_id=current_service.id),
permissions=['manage_service','manage_api_keys']
@@ -101,7 +100,7 @@
{% call settings_row(if_has_permission='email') %}
{{ text_field('Email branding') }}
{{ text_field('Your branding' if email_branding else 'GOV.UK') }}
{{ text_field('Your branding' if current_service.email_branding else 'GOV.UK') }}
{{ edit_field(
'Change',
url_for('.branding_request', service_id=current_service.id),
@@ -132,16 +131,16 @@
{% call settings_row(if_has_permission='sms') %}
{{ text_field('Text message sender') }}
{% call field(status='default' if default_sms_sender == "None" else '') %}
{{ default_sms_sender | string | nl2br | safe if default_sms_sender else 'None'}}
{% if sms_sender_count > 1 %}
{% call field(status='default' if current_service.default_sms_sender == "None" else '') %}
{{ current_service.default_sms_sender | string | nl2br | safe if current_service.default_sms_sender else 'None'}}
{% if current_service.count_sms_senders > 1 %}
<div class="hint">
{{ '…and %d more' | format(sms_sender_count - 1) }}
{{ '…and %d more' | format(current_service.count_sms_senders - 1) }}
</div>
{% endif %}
{% endcall %}
{{ edit_field(
'Manage' if sms_sender_count else 'Change',
'Manage' if current_service.count_sms_senders > 1 else 'Change',
url_for('.service_sms_senders',
service_id=current_service.id),
permissions=['manage_service','manage_api_keys']
@@ -151,7 +150,7 @@
{% call settings_row(if_has_permission='sms') %}
{{ text_field('Text messages start with service name') }}
{{ boolean_field(prefix_sms) }}
{{ boolean_field(current_service.prefix_sms) }}
{{ edit_field(
'Change',
url_for('.service_set_sms_prefix',
@@ -208,16 +207,16 @@
{% call settings_row(if_has_permission='letter') %}
{{ text_field('Sender addresses') }}
{% call field(status='default' if default_letter_contact_block == "Not set" else '') %}
{{ default_letter_contact_block | string | nl2br | safe if default_letter_contact_block else 'Not set'}}
{% if letter_contact_details_count > 1 %}
{% call field(status='default' if current_service.default_letter_contact_block == None else '') %}
{{ current_service.default_letter_contact_block | string | nl2br | safe if current_service.default_letter_contact_block else 'Not set'}}
{% if current_service.count_letter_contact_details > 1 %}
<div class="hint">
{{ '…and %d more' | format(letter_contact_details_count - 1) }}
{{ '…and %d more' | format(current_service.count_letter_contact_details - 1) }}
</div>
{% endif %}
{% endcall %}
{{ edit_field(
'Manage' if letter_contact_details_count else 'Change',
'Manage' if current_service.count_letter_contact_details else 'Change',
url_for('.service_letter_contact_details',
service_id=current_service.id),
permissions=['manage_service','manage_api_keys']
@@ -227,7 +226,7 @@
{% call settings_row(if_has_permission='letter') %}
{{ text_field('Letter branding') }}
{{ text_field(letter_branding) }}
{{ text_field(current_service.letter_branding) }}
{{ edit_field(
'Change',
url_for('.request_letter_branding', service_id=current_service.id),
@@ -253,7 +252,7 @@
{% endcall %}
</div>
{% if current_service.restricted %}
{% if current_service.trial_mode %}
<h2 class="heading-medium">Your service is in trial mode</h2>
<ul class='list list-bullet'>
@@ -297,7 +296,7 @@
) %}
{% call row() %}
{{ text_field('Organisation')}}
{{ optional_text_field(organisation or None) }}
{{ optional_text_field(current_service.organisation_name) }}
{{ edit_field('Change', url_for('.link_service_to_organisation', service_id=current_service.id)) }}
{% endcall %}
{% call row() %}
@@ -309,23 +308,23 @@
{% endcall %}
{% call row() %}
{{ text_field('Free text message allowance')}}
{{ text_field('{:,}'.format(free_sms_fragment_limit or 0)) }}
{{ 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(email_branding.name or 'GOV.UK') }}
{{ text_field(current_service.email_branding.name or 'GOV.UK') }}
{{ edit_field('Change', url_for('.service_set_email_branding', service_id=current_service.id)) }}
{% endcall %}
{% call row() %}
{{ text_field('Letter branding')}}
{{ text_field(letter_branding) }}
{{ text_field(current_service.letter_branding) }}
{{ edit_field('Change', url_for('.set_letter_branding', service_id=current_service.id)) }}
{% endcall %}
{% call row() %}
{{ text_field('Data retention')}}
{% call field() %}
{{ data_retention | join(', ', attribute='notification_type') }}
{{ current_service.data_retention | join(', ', attribute='notification_type') }}
{% endcall %}
{{ edit_field('Change', url_for('.data_retention', service_id=current_service.id)) }}
{% endcall %}
@@ -334,7 +333,7 @@
<ul>
<li class="bottom-gutter">
<a href="{{ url_for('.service_switch_live', service_id=current_service.id) }}" class="button">
{{ 'Make service live' if current_service.restricted else 'Revert service to trial mode' }}
{{ 'Make service live' if current_service.trial_mode else 'Revert service to trial mode' }}
</a>
</li>
<li class="bottom-gutter">
@@ -354,7 +353,7 @@
</li>
{% if 'sms' in current_service.permissions %}
<li class="bottom-gutter">
{% if not can_receive_inbound %}
{% if not current_service.has_permission('inbound_sms') %}
<a href="{{ url_for('.service_set_inbound_number', service_id=current_service.id, set_inbound_sms=True) }}" class="button">
Allow inbound sms
</a>

View File

@@ -25,7 +25,7 @@
</div>
</div>
<div class="user-list">
{% if not data_retention_settings %}
{% if not current_service.data_retention %}
<div class="user-list-item">
<span class="hint">You havent added any data retention</span>
</div>
@@ -36,7 +36,7 @@
field_headings_visible=False,
caption_visible=False
) %}
{% for item in data_retention_settings %}
{% for item in current_service.data_retention %}
{% call row() %}
{{ text_field(item.notification_type | format_notification_type)}}
{{ text_field(item.days_of_retention) }}

View File

@@ -22,12 +22,12 @@
{% endif %}
</div>
<div class="user-list">
{% if not reply_to_email_addresses %}
{% if not current_service.email_reply_to_addresses %}
<div class="user-list-item">
<span class="hint">You havent added any email reply-to addresses yet</span>
</div>
{% endif %}
{% for item in reply_to_email_addresses %}
{% for item in current_service.email_reply_to_addresses %}
<div class="user-list-item">
<h3>
<span class="heading-small">{{ item.email_address }}</span>&ensp;<span class="hint">
@@ -39,7 +39,7 @@
{% if current_user.has_permissions('manage_service') %}
<a class="user-list-edit-link" href="{{ url_for('.service_edit_email_reply_to', service_id =current_service.id, reply_to_email_id = item.id) }}">Change</a>
{% endif %}
{% if reply_to_email_addresses|length > 1 %}
{% if current_service.count_email_reply_to_addresses > 1 %}
{{ api_key(item.id, thing="ID") }}
{% endif %}
</div>
@@ -58,7 +58,7 @@
<p>
Set up separate email addresses to receive replies
from your users.
{% if current_service.restricted and not reply_to_email_addresses %}
{% if current_service.trial_mode and not current_service.has_email_reply_to_address %}
Your service cant go live until youve added at least one
reply-to address.
{% endif %}

View File

@@ -12,7 +12,7 @@
<div class="grid-row">
<div class="column-three-quarters">
<p>
Your letters have the {{ letter_branding }} logo.
Your letters have the {{ current_service.letter_branding }} logo.
</p>
<p>
<a href="{{ url_for('main.feedback', ticket_type='ask-question-give-feedback', body='letter-branding') }}">Contact support</a>

View File

@@ -10,7 +10,7 @@
{% block maincolumn_content %}
<h1 class="heading-large">Set Inbound Number</h1>
{% if service_has_inbound_number %}
{% if current_service.has_inbound_number %}
<p> This service already has an inbound number </p>
{{ page_footer(
back_link=url_for('.service_settings', service_id=current_service.id),

View File

@@ -13,7 +13,7 @@
<h1 class="heading-large">Receive text messages</h1>
{% if 'inbound_sms' in current_service.permissions %}
<p>
Your service can receive text messages sent to {{ inbound_number }}.
Your service can receive text messages sent to {{ current_service.inbound_number }}.
</p>
<p>
If you want to turn this feature off,

View File

@@ -22,7 +22,7 @@
Set up a separate email address to receive replies from
your users, then enter it here.
</p>
{% if current_service.restricted %}
{% if current_service.trial_mode %}
<p>
Your service cant go live until youve done this.
</p>

View File

@@ -21,12 +21,12 @@
{% endif %}
</div>
<div class="user-list">
{% if not sms_senders %}
{% if not current_service.sms_senders %}
<div class="user-list-item">
<span class="hint">You havent added any text message senders yet</span>
</div>
{% endif %}
{% for item in sms_senders %}
{% for item in current_service.sms_senders_with_hints %}
<div class="user-list-item">
<h3>
<span class="heading-small">{{ item.sms_sender }}</span>
@@ -40,7 +40,7 @@
{% if current_user.has_permissions('manage_service') %}
<a class="user-list-edit-link" href="{{ url_for('.service_edit_sms_sender', service_id=current_service.id, sms_sender_id = item.id) }}">Change</a>
{% endif %}
{% if sms_senders|length > 1 %}
{% if current_service.count_sms_senders > 1 %}
{{ api_key(item.id, thing="ID") }}
{% endif %}
</div>

View File

@@ -13,13 +13,14 @@
</div>
<nav>
{% for service in services %}
{% if service.templates and services|length > 1 %}
{% set templates = service.templates_by_type(current_service.permissions) %}
{% if templates and services|length > 1 %}
<h2 class="">
{{ service.name }}
</h2>
<div class="left-gutter-4-3 bottom-gutter-3-2">
{% endif %}
{% for template in service.templates %}
{% for template in templates %}
<h2 class="message-name">
<a href="{{ url_for('.copy_template', service_id=current_service.id, template_id=template.id, from_service=service.id) }}">{{ template.name }}</a>
</h2>
@@ -27,7 +28,7 @@
{{ message_count_label(1, template.template_type, suffix='')|capitalize }} template
</p>
{% endfor %}
{% if service.templates %}
{% if templates %}
</div>
{% endif %}
{% endfor %}

View File

@@ -19,7 +19,7 @@
<p>When you create a GOV.UK Notify account, youll start in trial mode. This lets you try out the service, but has some restrictions in place.</p>
<p>
You can remove these restrictions by
{% if current_service and current_service.restricted %}
{% if current_service and current_service.trial_mode %}
<a href="{{ url_for('.request_to_go_live', service_id=current_service.id) }}">requesting to go live</a>.
{% else %}
going live.