Files
notifications-api/app/v2/templates/get_templates.py
Leo Hemsted 0282a76bf7 rename template.serialize to serialize_for_v2
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
2020-07-06 16:42:31 +01:00

19 lines
634 B
Python

from flask import jsonify, request
from app import authenticated_service
from app.dao import templates_dao
from app.schema_validation import validate
from app.v2.templates import v2_templates_blueprint
from app.v2.templates.templates_schemas import get_all_template_request
@v2_templates_blueprint.route("", methods=['GET'])
def get_templates():
data = validate(request.args.to_dict(), get_all_template_request)
templates = templates_dao.dao_get_all_templates_for_service(authenticated_service.id, data.get('type'))
return jsonify(
templates=[template.serialize_for_v2() for template in templates]
), 200