diff --git a/app/assets/stylesheets/components/sms-message.scss b/app/assets/stylesheets/components/sms-message.scss
index 77ebe5d0d..ec702ee2f 100644
--- a/app/assets/stylesheets/components/sms-message.scss
+++ b/app/assets/stylesheets/components/sms-message.scss
@@ -47,10 +47,10 @@
z-index: 50;
}
+%sms-message-use-links,
.sms-message-use-links {
@include copy-19;
- margin-top: 52px;
a {
display: block;
@@ -65,6 +65,11 @@
}
+.sms-message-use-links-with-title {
+ @extend %sms-message-use-links;
+ margin-top: 52px;
+}
+
.sms-message-from {
@include bold-19;
display: block;
diff --git a/app/main/views/send.py b/app/main/views/send.py
index 3615523cc..574f7a390 100644
--- a/app/main/views/send.py
+++ b/app/main/views/send.py
@@ -79,7 +79,7 @@ def choose_template(service_id, template_type):
abort(404)
return render_template(
- 'views/choose-template.html',
+ 'views/templates/choose.html',
templates=[
Template(
template,
diff --git a/app/main/views/templates.py b/app/main/views/templates.py
index a5fe530b0..64634b1a5 100644
--- a/app/main/views/templates.py
+++ b/app/main/views/templates.py
@@ -1,10 +1,12 @@
from flask import request, render_template, redirect, url_for, flash, abort
from flask_login import login_required
+from utils.template import Template
+
from app.main import main
from app.utils import user_has_permissions
from app.main.forms import SMSTemplateForm, EmailTemplateForm
-from app import service_api_client
+from app import service_api_client, current_service
form_objects = {
@@ -18,6 +20,26 @@ page_headings = {
}
+@main.route("/services//templates/", methods=['GET'])
+@login_required
+@user_has_permissions(
+ 'view_activity',
+ 'send_texts',
+ 'send_emails',
+ 'manage_templates',
+ 'manage_api_keys',
+ admin_override=True, any_=True
+)
+def view_template(service_id, template_id):
+ return render_template(
+ 'views/templates/template.html',
+ template=Template(
+ service_api_client.get_service_template(service_id, template_id)['data'],
+ prefix=current_service['name']
+ )
+ )
+
+
@main.route("/services//templates/add-", methods=['GET', 'POST'])
@login_required
@user_has_permissions('manage_templates', admin_override=True)
@@ -48,7 +70,7 @@ def add_service_template(service_id, template_type):
)
-@main.route("/services//templates/", methods=['GET', 'POST'])
+@main.route("/services//templates//edit", methods=['GET', 'POST'])
@login_required
@user_has_permissions('manage_templates', admin_override=True)
def edit_service_template(service_id, template_id):
diff --git a/app/templates/views/choose-template.html b/app/templates/views/choose-template.html
deleted file mode 100644
index c3fd1fc00..000000000
--- a/app/templates/views/choose-template.html
+++ /dev/null
@@ -1,75 +0,0 @@
-{% extends "withnav_template.html" %}
-{% from "components/email-message.html" import email_message %}
-{% from "components/sms-message.html" import sms_message %}
-{% from "components/page-footer.html" import page_footer %}
-{% from "components/textbox.html" import textbox %}
-
-{% block page_title %}
- {{ page_heading }} – GOV.UK Notify
-{% endblock %}
-
-{% block maincolumn_content %}
-
- {% if not templates %}
-
- {{ page_heading }}
-
- {% if current_user.has_permissions(permissions=['manage_templates'], any_=True) %}
-
- There are no
- {{ 'email' if 'email' == template_type else 'text message' }}
- templates
-
- Add a new template
- {% else %}
- You need to ask your service manager to add templates before you can send messages
- {% endif %}
-
- {% else %}
-
-
-
-
{{ page_heading }}
-
- {% if current_user.has_permissions(permissions=['manage_templates'], admin_override=True) %}
-
- {% endif %}
-
-
-
- {% for template in templates %}
-
- {% if 'email' == template_type %}
- {{ email_message(
- None,
- template.formatted_as_markup,
- name=template.name,
- ) }}
- {% elif 'sms' == template_type %}
- {{ sms_message(
- template.formatted_as_markup,
- name=template.name
- ) }}
- {% endif %}
-
-
-
- {% if current_user.has_permissions(permissions=['send_texts', 'send_emails', 'send_letters']) %}
-
Send from a CSV file
-
Send yourself a test
- {% endif %}
- {% if current_user.has_permissions(permissions=['manage_api_keys']) %}
-
API integration
- {% endif %}
- {% if current_user.has_permissions(permissions=['manage_templates'], admin_override=True) %}
-
Edit template
- {% endif %}
-
-
- {% endfor %}
-
- {% endif %}
-
-{% endblock %}
diff --git a/app/templates/views/dashboard/template-statistics.html b/app/templates/views/dashboard/template-statistics.html
index 631b0b11c..2a995f1c5 100644
--- a/app/templates/views/dashboard/template-statistics.html
+++ b/app/templates/views/dashboard/template-statistics.html
@@ -6,7 +6,7 @@
field_headings=['Template', hidden_field_heading('Type'), right_aligned_field_heading('Messages sent')]
) %}
{% call field() %}
-
+
{{ item.template.name }}
{% endcall %}
diff --git a/app/templates/views/notifications.html b/app/templates/views/notifications.html
index bf0a6dd0a..6c669f521 100644
--- a/app/templates/views/notifications.html
+++ b/app/templates/views/notifications.html
@@ -20,6 +20,7 @@
Successful messages
Failed messages
+
{% call(item, row_number) list_table(
notifications,
caption="Recent activity",
@@ -31,7 +32,7 @@
{{ item.to }}
{% endcall %}
{% call field() %}
- {{ item.template.name }}
+ {{ item.template.name }}
{% endcall %}
{% call field() %}
{{ item.template.template_type }}
diff --git a/app/templates/views/templates/_template.html b/app/templates/views/templates/_template.html
new file mode 100644
index 000000000..deb452b9e
--- /dev/null
+++ b/app/templates/views/templates/_template.html
@@ -0,0 +1,31 @@
+{% from "components/email-message.html" import email_message %}
+{% from "components/sms-message.html" import sms_message %}
+
+
+ {% if 'email' == template.template_type %}
+ {{ email_message(
+ None,
+ template.formatted_as_markup,
+ name=template.name if show_title else None
+ ) }}
+ {% elif 'sms' == template.template_type %}
+ {{ sms_message(
+ template.formatted_as_markup,
+ name=template.name if show_title else None
+ ) }}
+ {% endif %}
+
+
+
+ {% if current_user.has_permissions(permissions=['send_texts', 'send_emails', 'send_letters']) %}
+
Send from a CSV file
+
Send yourself a test
+ {% endif %}
+ {% if current_user.has_permissions(permissions=['manage_api_keys']) %}
+
API integration
+ {% endif %}
+ {% if current_user.has_permissions(permissions=['manage_templates'], admin_override=True) %}
+
Edit template
+ {% endif %}
+
+
\ No newline at end of file
diff --git a/app/templates/views/templates/choose.html b/app/templates/views/templates/choose.html
new file mode 100644
index 000000000..a9be181c7
--- /dev/null
+++ b/app/templates/views/templates/choose.html
@@ -0,0 +1,45 @@
+{% extends "withnav_template.html" %}
+
+{% block page_title %}
+ {{ page_heading }} – GOV.UK Notify
+{% endblock %}
+
+{% block maincolumn_content %}
+
+ {% if not templates %}
+
+ {{ page_heading }}
+
+ {% if current_user.has_permissions(permissions=['manage_templates'], any_=True) %}
+
+ You need a template before you can send
+ {{ 'emails' if 'email' == template_type else 'text messages' }}
+
+ Add a new template
+ {% else %}
+ You need to ask your service manager to add templates before you can send messages
+ {% endif %}
+
+ {% else %}
+
+
+
+
{{ page_heading }}
+
+ {% if current_user.has_permissions(permissions=['manage_templates'], admin_override=True) %}
+
+ {% endif %}
+
+
+
+ {% for template in templates %}
+ {% with show_title=True %}
+ {% include 'views/templates/_template.html' %}
+ {% endwith %}
+ {% endfor %}
+
+ {% endif %}
+
+{% endblock %}
diff --git a/app/templates/views/templates/template.html b/app/templates/views/templates/template.html
new file mode 100644
index 000000000..8a6ec558b
--- /dev/null
+++ b/app/templates/views/templates/template.html
@@ -0,0 +1,28 @@
+{% extends "withnav_template.html" %}
+{% from "components/email-message.html" import email_message %}
+{% from "components/sms-message.html" import sms_message %}
+{% from "components/page-footer.html" import page_footer %}
+{% from "components/textbox.html" import textbox %}
+
+{% block page_title %}
+ {{ template.name }} – GOV.UK Notify
+{% endblock %}
+
+{% block maincolumn_content %}
+
+
+ {{ template.name }}
+
+
+ {% include 'views/templates/_template.html' %}
+
+
+
+
+ All
+ {{ 'email' if 'email' == template.template_type else 'text message' }}
+ templates
+
+
+
+{% endblock %}