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

@@ -1,4 +1,4 @@
from flask import url_for
from flask import url_for, abort
from app import notifications_api_client
from app.main.utils import BrowsableItem
@@ -17,9 +17,24 @@ def get_service_templates(service_id):
return notifications_api_client.get_service_templates(service_id)
def get_service_template(service_id, template_id):
return notifications_api_client.get_service_template(
service_id, template_id)
def get_service_templates_or_404(service_id):
try:
get_service_templates(service_id)
except HTTPError as e:
if e.status_code == 404:
abort(404)
else:
raise e
def get_service_template_or_404(service_id, template_id):
try:
return notifications_api_client.get_service_template(service_id, template_id)
except HTTPError as e:
if e.status_code == 404:
abort(404)
else:
raise e
def delete_service_template(service_id, template_id):