mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-24 01:11:38 -05:00
27 lines
882 B
Python
27 lines
882 B
Python
import uuid
|
|
|
|
from flask import jsonify, request
|
|
from jsonschema.exceptions import ValidationError
|
|
from werkzeug.exceptions import abort
|
|
|
|
from app import api_user
|
|
from app.dao import templates_dao
|
|
from app.schema_validation import validate
|
|
from app.v2.template import v2_template_blueprint
|
|
from app.v2.template.template_schemas import get_template_by_id_request
|
|
|
|
|
|
@v2_template_blueprint.route("/<template_id>", methods=['GET'])
|
|
@v2_template_blueprint.route("/<template_id>/version/<int:version>", methods=['GET'])
|
|
def get_template_by_id(template_id, version=None):
|
|
_data = {'id': template_id}
|
|
if version:
|
|
_data['version'] = version
|
|
|
|
data = validate(_data, get_template_by_id_request)
|
|
|
|
template = templates_dao.dao_get_template_by_id_and_service_id(
|
|
template_id, api_user.service_id, data.get('version'))
|
|
|
|
return jsonify(template.serialize()), 200
|