[utils] Add util to get pagination filter args from request

This commit is contained in:
Ferdinand Thiessen 2021-11-25 15:40:15 +01:00
parent 41f625aabc
commit 1609d8ae29
1 changed files with 18 additions and 0 deletions

View File

@ -2,6 +2,24 @@ from http.client import NO_CONTENT, CREATED
from flask import make_response, jsonify
from flaschengeist.utils.datetime import from_iso_format
def get_filter_args():
"""
Get filter parameter from request
returns: FROM, TO, LIMIT, OFFSET, DESCENDING
"""
from flask import request
return (
request.args.get("from", type=from_iso_format),
request.args.get("to", type=from_iso_format),
request.args.get("limit", type=int),
request.args.get("offset", type=int),
"descending" in request.args,
)
def no_content():
return make_response(jsonify(""), NO_CONTENT)