mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-03 12:00:12 +03:00
Added IsAnonymousOrReadOnly permission
This commit is contained in:
parent
522d453546
commit
69cf7169f4
|
@ -210,3 +210,15 @@ class DjangoObjectPermissions(DjangoModelPermissions):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
class IsAnonymousOrReadOnly(BasePermission):
|
||||||
|
"""
|
||||||
|
The request from anonymous user is accepted, or is a read-only request.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def has_permission(self, request, view):
|
||||||
|
return (
|
||||||
|
request.method in SAFE_METHODS or
|
||||||
|
request.user and
|
||||||
|
request.user.is_anonymous
|
||||||
|
)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user