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

20 lines
635 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 jsonschema.exceptions import ValidationError
from app import api_user
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():
2017-03-28 13:15:39 +01:00
validate(request.args.to_dict(), get_all_template_request)
2017-03-28 10:41:25 +01:00
2017-03-28 13:15:39 +01:00
templates = templates_dao.dao_get_all_templates_for_service(api_user.service_id)
2017-03-28 10:41:25 +01:00
return jsonify(
2017-03-28 13:15:39 +01:00
templates=[template.serialize() for template in templates]
2017-03-28 10:41:25 +01:00
), 200