mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-02-05 10:53:28 -05:00
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:
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user