aboutsummaryrefslogtreecommitdiffstats
path: root/rest_framework/permissions.py
diff options
context:
space:
mode:
authorTom Christie2013-12-23 09:48:59 +0000
committerTom Christie2013-12-23 09:48:59 +0000
commit52686420f4bf866064ee88a15903665f14289394 (patch)
tree41ea7b0d4863092f996f63de14e678a1c74a7a3a /rest_framework/permissions.py
parent9c41c007afc71c899306bcb02e40bdfc36b09146 (diff)
parent83b31e7ea298a8948e9a76c9b971845ea0052b3c (diff)
downloaddjango-rest-framework-52686420f4bf866064ee88a15903665f14289394.tar.bz2
Merge branch 'bennbollay-patch-1' into 2.4.0
Conflicts: .travis.yml docs/api-guide/routers.md rest_framework/compat.py tox.ini
Diffstat (limited to 'rest_framework/permissions.py')
-rw-r--r--rest_framework/permissions.py22
1 files changed, 7 insertions, 15 deletions
diff --git a/rest_framework/permissions.py b/rest_framework/permissions.py
index d93dba19..c9517138 100644
--- a/rest_framework/permissions.py
+++ b/rest_framework/permissions.py
@@ -44,9 +44,7 @@ class IsAuthenticated(BasePermission):
"""
def has_permission(self, request, view):
- if request.user and request.user.is_authenticated():
- return True
- return False
+ return request.user and request.user.is_authenticated()
class IsAdminUser(BasePermission):
@@ -55,9 +53,7 @@ class IsAdminUser(BasePermission):
"""
def has_permission(self, request, view):
- if request.user and request.user.is_staff:
- return True
- return False
+ return request.user and request.user.is_staff
class IsAuthenticatedOrReadOnly(BasePermission):
@@ -66,11 +62,9 @@ class IsAuthenticatedOrReadOnly(BasePermission):
"""
def has_permission(self, request, view):
- if (request.method in SAFE_METHODS or
- request.user and
- request.user.is_authenticated()):
- return True
- return False
+ return (request.method in SAFE_METHODS or
+ request.user and
+ request.user.is_authenticated())
class DjangoModelPermissions(BasePermission):
@@ -128,11 +122,9 @@ class DjangoModelPermissions(BasePermission):
perms = self.get_required_permissions(request.method, model_cls)
- if (request.user and
+ return (request.user and
(request.user.is_authenticated() or not self.authenticated_users_only) and
- request.user.has_perms(perms)):
- return True
- return False
+ request.user.has_perms(perms))
class DjangoModelPermissionsOrAnonReadOnly(DjangoModelPermissions):