Add some SMS messages to the choose template page

This commit is contained in:
Chris Hill-Scott
2016-01-13 16:21:29 +00:00
parent fe0774066d
commit c7f635be4a
6 changed files with 57 additions and 25 deletions

View File

@@ -45,4 +45,9 @@
margin: -$gutter-half 0 $gutter 0;
}
&-name {
@include bold-19;
margin: 0 0 5px 0;
}
}

View File

@@ -0,0 +1,20 @@
sms_templates = [
{
'name': 'Reminder',
'body': """
Vehicle tax: Your vehicle tax for ((registration number)) expires on ((date)).
Tax your vehicle at www.gov.uk/vehicle-tax
"""
},
{
'name': 'Warning',
'body': """
Vehicle tax: Your vehicle tax for ((registration number)) has expired.
Tax your vehicle at www.gov.uk/vehicle-tax
"""
},
]
email_templates = [
]

View File

@@ -22,23 +22,7 @@ from app.main import main
from app.main.forms import CsvUploadForm
from app.main.uploader import s3upload
# TODO move this to the templates directory
message_templates = [
{
'name': 'Reminder',
'body': """
Vehicle tax: Your vehicle tax for ((registration number)) expires on ((date)).
Tax your vehicle at www.gov.uk/vehicle-tax
"""
},
{
'name': 'Warning',
'body': """
Vehicle tax: Your vehicle tax for ((registration number)) has expired.
Tax your vehicle at www.gov.uk/vehicle-tax
"""
},
]
from ._templates import sms_templates
@main.route("/services/<int:service_id>/sms/send", methods=['GET', 'POST'])
@@ -66,7 +50,7 @@ def sendsms(service_id):
return redirect(url_for('.sendsms', service_id=service_id))
return render_template('views/send-sms.html',
message_templates=message_templates,
message_templates=sms_templates,
form=form,
service_id=service_id)
@@ -88,7 +72,7 @@ def checksms(service_id):
'views/check-sms.html',
upload_result=upload_result,
filename=filename,
message_template=message_templates[0]['body'],
message_template=sms_templates[0]['body'],
service_id=service_id
)
elif request.method == 'POST':

View File

@@ -4,13 +4,17 @@ from flask_login import login_required
from app.main import main
from app.main.forms import TemplateForm
from ._templates import sms_templates, email_templates
@main.route("/services/<int:service_id>/templates")
@login_required
def manage_templates(service_id):
return render_template(
'views/manage-templates.html',
service_id=service_id
service_id=service_id,
sms_templates=sms_templates,
email_templates=email_templates
)

View File

@@ -1,4 +1,12 @@
{% macro sms_message(body, recipient) %}
{% macro sms_message(body, recipient=None, name=None, edit_link=None) %}
{% if name %}
<h3 class="sms-message-name">
{{ name }}
{% if edit_link %}
<a href="{{ edit_link }}">Edit</a>
{% endif %}
</h3>
{% endif %}
<div class="sms-message">
<div class="sms-message-wrapper">
{{ body|placeholders }}

View File

@@ -1,4 +1,5 @@
{% extends "withnav_template.html" %}
{% from "components/sms-message.html" import sms_message %}
{% block page_title %}
GOV.UK Notify | Manage templates
@@ -9,11 +10,21 @@ GOV.UK Notify | Manage templates
<h1 class="heading-xlarge">Manage templates</h1>
<p>Here's where you can view templates, choose to add one, or edit/delete one.</p>
<h2 class="heading-medium">SMS templates</h2>
<p>
<a href="{{ url_for('.edit_template', service_id=service_id, template_id=1) }}">Here is my first template</a>
</p>
<div class="grid-row">
<div class="column-two-thirds">
{% for template in sms_templates %}
{{ sms_message(
template.body,
name=template.name,
edit_link=url_for('.edit_template', service_id=service_id, template_id=1)
) }}
{% endfor %}
</div>
</div>
<p>
<a class="button" href="{{ url_for('.add_template', service_id=service_id) }}" role="button">Add a new message template</a>