Files
notifications-api/app/v2/templates/get_templates.py

22 lines
659 B
Python
Raw Normal View History

2017-03-28 13:15:39 +01:00
from flask import jsonify, request
2017-03-28 10:41:25 +01:00
from app import authenticated_service
2017-03-28 10:41:25 +01:00
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
2023-08-29 14:54:30 -07:00
@v2_templates_blueprint.route("", methods=["GET"])
2017-03-28 10:41:25 +01:00
def get_templates():
data = validate(request.args.to_dict(), get_all_template_request)
2017-03-28 10:41:25 +01:00
2023-08-29 14:54:30 -07:00
templates = templates_dao.dao_get_all_templates_for_service(
authenticated_service.id, data.get("type")
)
2017-03-28 10:41:25 +01:00
2023-08-29 14:54:30 -07:00
return (
jsonify(templates=[template.serialize_for_v2() for template in templates]),
200,
)