aboutsummaryrefslogtreecommitdiffstats
path: root/djangorestframework/views.py
diff options
context:
space:
mode:
Diffstat (limited to 'djangorestframework/views.py')
-rw-r--r--djangorestframework/views.py17
1 files changed, 15 insertions, 2 deletions
diff --git a/djangorestframework/views.py b/djangorestframework/views.py
index f6a7a3bf..2ce36a9a 100644
--- a/djangorestframework/views.py
+++ b/djangorestframework/views.py
@@ -68,7 +68,7 @@ _resource_classes = (
)
-class View(ResourceMixin, PermissionsMixin, DjangoView):
+class View(ResourceMixin, DjangoView):
"""
Handles incoming requests and maps them to REST operations.
Performs request deserialization, response serialization, authentication and input validation.
@@ -96,7 +96,7 @@ class View(ResourceMixin, PermissionsMixin, DjangoView):
List of all authenticating methods to attempt.
"""
- permissions = (permissions.FullAnonAccess,)
+ permission_classes = (permissions.FullAnonAccess,)
"""
List of all permissions that must be checked.
"""
@@ -223,6 +223,19 @@ class View(ResourceMixin, PermissionsMixin, DjangoView):
"""
return self.renderers[0]
+ def get_permissions(self):
+ """
+ Instantiates and returns the list of permissions that this view requires.
+ """
+ return [permission(self) for permission in self.permission_classes]
+
+ def check_permissions(self, user):
+ """
+ Check user permissions and either raise an ``ImmediateResponse`` or return.
+ """
+ for permission in self.get_permissions():
+ permission.check_permission(user)
+
def initial(self, request, *args, **kargs):
"""
This method is a hook for any code that needs to run prior to