From 7d29e6204e1ed3d5e5d71842e541a8ea3ad279a9 Mon Sep 17 00:00:00 2001 From: Cédric Bonhomme Date: Mon, 12 Oct 2020 00:55:30 +0200 Subject: chg: [API] allow search with filters from controllers for articles. --- newspipe/web/views/api/v2/common.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/newspipe/web/views/api/v2/common.py b/newspipe/web/views/api/v2/common.py index 332c07f8..d785dda5 100644 --- a/newspipe/web/views/api/v2/common.py +++ b/newspipe/web/views/api/v2/common.py @@ -109,6 +109,13 @@ class PyAggAbstractResource(Resource): parser.add_argument( attr_name, location="json", default=in_values[attr_name] ) + + if not default: + for value in in_values: + parser.add_argument( + value, location="json", default=in_values[value] + ) + return parser.parse_args(req=request.args, strict=strict) @@ -146,6 +153,7 @@ class PyAggResourceMulti(PyAggAbstractResource): try: limit = request.json.pop("limit", 10) order_by = request.json.pop("order_by", None) + args = self.reqparse_args(right="read", default=True) except Exception: args = self.reqparse_args(right="read", default=False) limit = request.args.get("limit", 10) -- cgit