aboutsummaryrefslogtreecommitdiff
path: root/src/web/views/api/v3/common.py
diff options
context:
space:
mode:
authorCédric Bonhomme <cedric@cedricbonhomme.org>2016-04-19 14:05:24 +0200
committerCédric Bonhomme <cedric@cedricbonhomme.org>2016-04-19 14:05:24 +0200
commit8cc5fca2ca1592dfaaab5dc46de1c046b326fb7c (patch)
tree7dc14867ff2fc70538d9e4daf9991db745f7bcfa /src/web/views/api/v3/common.py
parentDefined an url prefix for the new API. (diff)
downloadnewspipe-8cc5fca2ca1592dfaaab5dc46de1c046b326fb7c.tar.gz
newspipe-8cc5fca2ca1592dfaaab5dc46de1c046b326fb7c.tar.bz2
newspipe-8cc5fca2ca1592dfaaab5dc46de1c046b326fb7c.zip
Added preprocessor for GET_MANY.
Diffstat (limited to 'src/web/views/api/v3/common.py')
-rw-r--r--src/web/views/api/v3/common.py17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/web/views/api/v3/common.py b/src/web/views/api/v3/common.py
index b4e6b62e..84e1f104 100644
--- a/src/web/views/api/v3/common.py
+++ b/src/web/views/api/v3/common.py
@@ -13,7 +13,7 @@ def auth_func(*args, **kw):
if not current_user.is_authenticated:
raise ProcessingException(description='Not authenticated!', code=401)
-def check_auth(instance_id=None, **kw):
+def get_single_preprocessor(instance_id=None, **kw):
# Check if the user is authorized to modify the specified
# instance of the model.
contr = ArticleController(current_user.id)
@@ -21,3 +21,18 @@ def check_auth(instance_id=None, **kw):
if not is_authorized_to_modify(current_user, article):
raise ProcessingException(description='Not Authorized',
code=401)
+
+def get_many_preprocessor(search_params=None, **kw):
+ """Accepts a single argument, `search_params`, which is a dictionary
+ containing the search parameters for the request.
+
+ """
+ filt = dict(name="user_id",
+ op="eq",
+ val=current_user.id)
+
+ # Check if there are any filters there already.
+ if "filters" not in search_params:
+ search_params["filters"] = []
+
+ search_params["filters"].append(filt)
bgstack15