Files
notifications-admin/app/main/views/templates.py
Chris Hill-Scott 4e8f8dead7 Add stubbed template_id to template pages
So that we can get a better sense of what the URLs look like.

Leaving unsigned for now because we don’t know if the ID will be a string or int
or…
2016-01-13 13:25:06 +00:00

52 lines
1.5 KiB
Python

from flask import request, render_template, redirect, url_for
from flask_login import login_required
from app.main import main
from app.main.forms import TemplateForm
@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
)
@main.route("/services/<int:service_id>/templates/add", methods=['GET', 'POST'])
@login_required
def add_template(service_id):
form = TemplateForm()
if request.method == 'GET':
return render_template(
'views/edit-template.html',
h1='Add template',
form=form,
service_id=service_id
)
elif request.method == 'POST':
return redirect(url_for('.manage_templates', service_id=service_id))
@main.route("/services/<int:service_id>/templates/<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
if request.method == 'GET':
return render_template(
'views/edit-template.html',
h1='Edit template',
form=form,
service_id=service_id
)
elif request.method == 'POST':
return redirect(url_for('.manage_templates', service_id=service_id))