Removed paging from get all templates

This commit is contained in:
Ken Tsang
2017-03-28 13:15:39 +01:00
parent e2ad8ba50d
commit d290a2e0ad
2 changed files with 24 additions and 75 deletions

View File

@@ -1,6 +1,4 @@
import json
from flask import jsonify, request, current_app, url_for
from flask import jsonify, request
from jsonschema.exceptions import ValidationError
from app import api_user
@@ -12,27 +10,10 @@ from app.v2.templates.templates_schemas import get_all_template_request
@v2_templates_blueprint.route("/", methods=['GET'])
def get_templates():
_data = request.args.to_dict()
validate(request.args.to_dict(), get_all_template_request)
data = validate(_data, get_all_template_request)
templates = templates_dao.dao_get_all_templates_for_service(
api_user.service_id,
older_than=data.get('older_than'),
page_size=current_app.config.get('API_PAGE_SIZE'))
def _build_links(templates):
_links = {
'current': url_for(".get_templates", _external=True, **data),
}
if len(templates):
next_query_params = dict(data, older_than=templates[-1].id)
_links['next'] = url_for(".get_templates", _external=True, **next_query_params)
return _links
templates = templates_dao.dao_get_all_templates_for_service(api_user.service_id)
return jsonify(
templates=[template.serialize() for template in templates],
links=_build_links(templates)
templates=[template.serialize() for template in templates]
), 200