Add endpoint for getting / creating a hidden template

We want a way of getting the hidden precompiled template from admin,
so this adds an endpoint which gets the template or creates it if it doesn't
exist. The function to get or create the hidden template already existed
but has been moved to the template DAO now that it is used in more
places.
This commit is contained in:
Katie Smith
2019-09-05 12:07:35 +01:00
parent 5cdce44e42
commit 0c1fa3852f
4 changed files with 85 additions and 30 deletions

View File

@@ -25,7 +25,9 @@ from app.dao.templates_dao import (
dao_get_all_templates_for_service,
dao_get_template_versions,
dao_update_template_reply_to,
dao_get_template_by_id)
dao_get_template_by_id,
get_precompiled_letter_template,
)
from app.errors import (
register_errors,
InvalidRequest
@@ -138,6 +140,14 @@ def update_template(service_id, template_id):
return jsonify(data=template_schema.dump(update_dict).data), 200
@template_blueprint.route('/precompiled', methods=['GET'])
def get_precompiled_template_for_service(service_id):
template = get_precompiled_letter_template(service_id)
template_dict = template_schema.dump(template).data
return jsonify(template_dict), 200
@template_blueprint.route('', methods=['GET'])
def get_all_templates_for_service(service_id):
templates = dao_get_all_templates_for_service(service_id=service_id)