aboutsummaryrefslogtreecommitdiffstats
path: root/rest_framework/permissions.py
diff options
context:
space:
mode:
authorTom Christie2013-04-30 14:34:28 +0100
committerTom Christie2013-04-30 14:34:28 +0100
commitb65b065375796919a57f4bd6f1dd8187ef0eb165 (patch)
tree7da258c8dd5dbee05ab88b126b53b67dd5ce5720 /rest_framework/permissions.py
parent8dff8d2fdcfcee356c134f4be8235d2a4f122d1a (diff)
downloaddjango-rest-framework-b65b065375796919a57f4bd6f1dd8187ef0eb165.tar.bz2
Add DjangoModelPermissionsOrAnonReadOnly
Diffstat (limited to 'rest_framework/permissions.py')
-rw-r--r--rest_framework/permissions.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/rest_framework/permissions.py b/rest_framework/permissions.py
index 91bf5ad6..751f31a7 100644
--- a/rest_framework/permissions.py
+++ b/rest_framework/permissions.py
@@ -89,8 +89,8 @@ class DjangoModelPermissions(BasePermission):
It ensures that the user is authenticated, and has the appropriate
`add`/`change`/`delete` permissions on the model.
- This permission will only be applied against view classes that
- provide a `.model` attribute, such as the generic class-based views.
+ This permission can only be applied against view classes that
+ provide a `.model` or `.queryset` attribute.
"""
# Map methods into required permission codes.
@@ -138,6 +138,14 @@ class DjangoModelPermissions(BasePermission):
return False
+class DjangoModelPermissionsOrAnonReadOnly(DjangoModelPermissions):
+ """
+ Similar to DjangoModelPermissions, except that anonymous users are
+ allowed read-only access.
+ """
+ authenticated_users_only = False
+
+
class TokenHasReadWriteScope(BasePermission):
"""
The request is authenticated as a user and the token used has the right scope