Refactor settings page to use service model

There’s a lot of code in service settings which:
- talks to the API directly through the clients
- passes that information through to the Jinja template

By encapsulating this logic in the service model:
- the Jinja template can access the data directly
- the logic can be reused across multiple methods
This commit is contained in:
Chris Hill-Scott
2018-10-26 17:31:49 +01:00
parent 526f2d7900
commit 1e2608d2e0
12 changed files with 199 additions and 159 deletions

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.trial_mode 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 %}