diff options
author | François Schmidts <francois.schmidts@gmail.com> | 2015-08-05 16:05:29 +0200 |
---|---|---|
committer | François Schmidts <francois.schmidts@gmail.com> | 2015-08-05 16:11:29 +0200 |
commit | 5e0aca072dc5ecb6a041f996e3b4ad5ef6d1205c (patch) | |
tree | 6d8868083d33197e7ea2032e9caa8f3b4ad0aec2 /pyaggr3g470r/views/api | |
parent | refact feed list (diff) | |
download | newspipe-5e0aca072dc5ecb6a041f996e3b4ad5ef6d1205c.tar.gz newspipe-5e0aca072dc5ecb6a041f996e3b4ad5ef6d1205c.tar.bz2 newspipe-5e0aca072dc5ecb6a041f996e3b4ad5ef6d1205c.zip |
making it easier to request with lists
Diffstat (limited to 'pyaggr3g470r/views/api')
-rw-r--r-- | pyaggr3g470r/views/api/common.py | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/pyaggr3g470r/views/api/common.py b/pyaggr3g470r/views/api/common.py index a7068807..acb5dd68 100644 --- a/pyaggr3g470r/views/api/common.py +++ b/pyaggr3g470r/views/api/common.py @@ -161,17 +161,17 @@ class PyAggResourceMulti(PyAggAbstractResource): """retrieve several objects. filters can be set in the payload on the different fields of the object, and a limit can be set in there as well """ - if 'application/json' not in request.headers.get('Content-Type'): - raise BadRequest("Content-Type must be application/json") - limit = 10 try: limit = request.json.pop('limit', 10) + order_by = request.json.pop('order_by', None) + query = self.controller.read(**request.json) except: - return [res for res in self.controller.read().limit(limit)] - if not limit: - return [res for res in self.controller.read(**request.json).all()] - return [res - for res in self.controller.read(**request.json).limit(limit)] + limit, order_by, query = 10, None, self.controller.read() + if order_by: + query = query.order_by(order_by) + if limit: + query = query.limit(limit) + return [res for res in query] def post(self): """creating several objects. payload should be a list of dict. |