aboutsummaryrefslogtreecommitdiff
path: root/src/web/views/api/v3/common.py
diff options
context:
space:
mode:
authorCédric Bonhomme <cedric@cedricbonhomme.org>2016-04-26 10:00:19 +0200
committerCédric Bonhomme <cedric@cedricbonhomme.org>2016-04-26 10:00:19 +0200
commit2e2eee1cc691b91f475d33458a24315b2a313541 (patch)
treef189556e9555f6e36f39d51dadae8f4964008210 /src/web/views/api/v3/common.py
parentMerge branch 'new-api' of github.com:JARR/JARR into new-api (diff)
downloadnewspipe-2e2eee1cc691b91f475d33458a24315b2a313541.tar.gz
newspipe-2e2eee1cc691b91f475d33458a24315b2a313541.tar.bz2
newspipe-2e2eee1cc691b91f475d33458a24315b2a313541.zip
Improved the Web services processors.
Diffstat (limited to 'src/web/views/api/v3/common.py')
-rw-r--r--src/web/views/api/v3/common.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/web/views/api/v3/common.py b/src/web/views/api/v3/common.py
index bd20ad38..51e4e6be 100644
--- a/src/web/views/api/v3/common.py
+++ b/src/web/views/api/v3/common.py
@@ -25,9 +25,12 @@ def auth_func(*args, **kw):
raise ProcessingException(description='Not authenticated!', code=401)
class AbstractProcessor():
+ """Abstract processors for the Web services.
+ """
def is_authorized(self, user, obj):
- return user.id == obj.user_id
+ if user.id != obj.user_id:
+ raise ProcessingException(description='Not Authorized', code=401)
def get_single_preprocessor(self, instance_id=None, **kw):
# Check if the user is authorized to modify the specified
@@ -48,7 +51,14 @@ class AbstractProcessor():
search_params["filters"].append(filt)
- def post_put_preprocessor(self, data=None, **kw):
+ def post_preprocessor(self, data=None, **kw):
+ pass
+
+ def put_single_preprocessor(instance_id=None, data=None, **kw):
+ """Accepts two arguments, `instance_id`, the primary key of the
+ instance of the model to patch, and `data`, the dictionary of fields
+ to change on the instance.
+ """
pass
def delete_preprocessor(self, instance_id=None, **kw):
bgstack15