2017-03-28 13:15:39 +01:00
|
|
|
from flask import jsonify, request
|
2017-03-28 10:41:25 +01:00
|
|
|
|
2017-05-05 15:23:06 +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
|
|
|
|
|
|
|
|
|
|
|
2017-04-19 12:38:58 +01:00
|
|
|
@v2_templates_blueprint.route("", methods=['GET'])
|
2017-03-28 10:41:25 +01:00
|
|
|
def get_templates():
|
2017-04-18 16:19:25 +01:00
|
|
|
data = validate(request.args.to_dict(), get_all_template_request)
|
2017-03-28 10:41:25 +01:00
|
|
|
|
2017-05-05 15:23:06 +01:00
|
|
|
templates = templates_dao.dao_get_all_templates_for_service(authenticated_service.id, data.get('type'))
|
2017-03-28 10:41:25 +01:00
|
|
|
|
|
|
|
|
return jsonify(
|
2020-07-06 16:41:53 +01:00
|
|
|
templates=[template.serialize_for_v2() for template in templates]
|
2017-03-28 10:41:25 +01:00
|
|
|
), 200
|