Use Template to replace/highlight placeholders

This commit brings in the `Template` util, added here:
https://github.com/alphagov/notifications-utils/pull/1

It also does a fair bit of tidying up, which I’ve unfortunately squashed into
this one massive commit. The main change is moving 404 handling into the
templates dao, so that every view isn’t littered with `try: … except(HTTPError)`.

It also adds new features, in a prototypy sort of way, which are:
- download a prefilled example CSV
- show all the columns for your template on the 'check' page
This commit is contained in:
Chris Hill-Scott
2016-02-08 16:36:53 +00:00
parent b7c226e2a8
commit 2d55bb7ae2
13 changed files with 127 additions and 101 deletions

View File

@@ -8,6 +8,7 @@ from flask import (
)
from flask_login import login_required
from notifications_python_client.errors import HTTPError
from utils.template import Template
from app import job_api_client
from app.main import main
@@ -38,7 +39,6 @@ def view_jobs(service_id):
def view_job(service_id, job_id):
try:
job = job_api_client.get_job(service_id, job_id)['data']
template = templates_dao.get_service_template(service_id, job['template'])['data']
messages = []
return render_template(
'views/job.html',
@@ -55,7 +55,9 @@ def view_job(service_id, job_id):
cost=u'£0.00',
uploaded_file_name=job['original_file_name'],
uploaded_file_time=job['created_at'],
template=template,
template=Template(
templates_dao.get_service_template_or_404(service_id, job['template'])['data']
),
service_id=service_id
)
except HTTPError as e: