[utils] Add util to get pagination filter args from request
This commit is contained in:
parent
c3468eea03
commit
46c41578e5
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue