Add a prototype email template

If the templates page contains text messages and emails then there’s two ways it
could be structured:
- into two sections, all text messages first, then all emails
- emails and text messages interleaved, sorted by date

I think the second one is better. Imagine a situation where you mostly do emails
but have a few text messages. You’d have to scroll past the text messages to get
to your emails. Every time.

I reckon that the most commonly accessed templates will be the most recent ones.
This commit is contained in:
Chris Hill-Scott
2016-01-13 16:27:54 +00:00
parent c7f635be4a
commit 75c92c12c1
12 changed files with 134 additions and 43 deletions

View File

@@ -1,20 +1,39 @@
sms_templates = [
templates = [
{
'type': 'sms',
'name': 'Confirmation',
'body': 'Lasting power of attorney: Weve received your application. Applications take between 8 and 10 weeks to process.' # noqa
},
{
'type': 'sms',
'name': 'Reminder',
'body': """
Vehicle tax: Your vehicle tax for ((registration number)) expires on ((date)).
Tax your vehicle at www.gov.uk/vehicle-tax
'body': 'Vehicle tax: Your vehicle tax for ((registration number)) expires on ((date)). Tax your vehicle at www.gov.uk/vehicle-tax' # noqa
},
{
'type': 'sms',
'name': 'Warning',
'body': 'Vehicle tax: Your vehicle tax for ((registration number)) has expired. Tax your vehicle at www.gov.uk/vehicle-tax' # noqa
},
{
'type': 'email',
'name': 'Application alert 06/2016',
'subject': 'Your lasting power of attorney application',
'body': """Dear ((name)),
When youve made your lasting power of attorney (LPA), you need to register it \
with the Office of the Public Guardian (OPG).
You can apply to register your LPA yourself if youre able to make your own decisions.
Your attorney can also register it for you. Youll be told if they do and you can \
object to the registration.
It takes between 8 and 10 weeks to register an LPA if there are no mistakes in the application.
"""
},
{
'name': 'Warning',
'body': """
Vehicle tax: Your vehicle tax for ((registration number)) has expired.
Tax your vehicle at www.gov.uk/vehicle-tax
"""
'type': 'sms',
'name': 'Air quality alert',
'body': 'Air pollution levels will be ((level)) in ((region)) tomorrow.'
},
]
email_templates = [
]

View File

@@ -22,7 +22,11 @@ from app.main import main
from app.main.forms import CsvUploadForm
from app.main.uploader import s3upload
from ._templates import sms_templates
from ._templates import templates
sms_templates = [
template for template in templates if template['type'] == 'sms'
]
@main.route("/services/<int:service_id>/sms/send", methods=['GET', 'POST'])

View File

@@ -4,7 +4,7 @@ from flask_login import login_required
from app.main import main
from app.main.forms import TemplateForm
from ._templates import sms_templates, email_templates
from ._templates import templates
@main.route("/services/<int:service_id>/templates")
@@ -13,8 +13,7 @@ def manage_templates(service_id):
return render_template(
'views/manage-templates.html',
service_id=service_id,
sms_templates=sms_templates,
email_templates=email_templates
templates=templates,
)
@@ -35,14 +34,14 @@ def add_template(service_id):
return redirect(url_for('.manage_templates', service_id=service_id))
@main.route("/services/<int:service_id>/templates/<template_id>", methods=['GET', 'POST'])
@main.route("/services/<int:service_id>/templates/<int:template_id>", methods=['GET', 'POST'])
@login_required
def edit_template(service_id, template_id):
form = TemplateForm()
form.template_name.data = 'Reminder'
form.template_body.data = 'Vehicle tax: Your vehicle tax for ((registration number)) expires on ((date)). Tax your vehicle at www.gov.uk/vehicle-tax' # noqa
form.template_name.data = templates[template_id - 1]['name']
form.template_body.data = templates[template_id - 1]['body']
if request.method == 'GET':
return render_template(