Template history endpoint added. All tests passing.

Code quality fix.
This commit is contained in:
Nicholas Staples
2016-05-06 15:42:43 +01:00
parent e10728ccae
commit 9b3d4a6087
6 changed files with 117 additions and 15 deletions

View File

@@ -15,7 +15,7 @@ from app.dao.templates_dao import (
)
from notifications_utils.template import Template
from app.dao.services_dao import dao_fetch_service_by_id
from app.schemas import template_schema
from app.schemas import (template_schema, template_history_schema)
template = Blueprint('template', __name__, url_prefix='/service/<uuid:service_id>/template')
@@ -96,5 +96,18 @@ def get_template_by_id_and_service_id(service_id, template_id):
return jsonify(data=data)
@template.route('/<uuid:template_id>/version/<int:version>')
def get_template_version(service_id, template_id, version):
fetched_template = dao_get_template_by_id_and_service_id(
template_id=template_id,
service_id=service_id,
version=version
)
data, errors = template_history_schema.dump(fetched_template)
if errors:
return json_resp(result=error, message=errors), 400
return jsonify(data=data)
def _strip_html(content):
return bleach.clean(content, tags=[], strip=True)