mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-22 08:21:13 -05:00
make it clear that this is for the public api, and we shouldn't add fields to it without considering impacts also add the broadcast_messages relationship on service and template to the exclude from the marshmallow schemas, so it's not included elsewhere
22 lines
796 B
Python
22 lines
796 B
Python
from flask import jsonify
|
|
|
|
from app import authenticated_service
|
|
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, authenticated_service.id, data.get('version'))
|
|
return jsonify(template.serialize_for_v2()), 200
|