Call User.is_authenticated and User.is_anonymous as properties
This commit is contained in:
parent
7fa7106d72
commit
b6cf0c34f5
|
@ -23,7 +23,7 @@ class APIRoot(views.APIView):
|
||||||
'accountancy': {},
|
'accountancy': {},
|
||||||
'services': {},
|
'services': {},
|
||||||
}
|
}
|
||||||
if not request.user.is_anonymous():
|
if not request.user.is_anonymous:
|
||||||
list_name = '{basename}-list'
|
list_name = '{basename}-list'
|
||||||
detail_name = '{basename}-detail'
|
detail_name = '{basename}-detail'
|
||||||
for prefix, viewset, basename in self.router.registry:
|
for prefix, viewset, basename in self.router.registry:
|
||||||
|
|
|
@ -14,7 +14,7 @@ class OrchestraPermissionBackend(DjangoModelPermissions):
|
||||||
model_cls = queryset.model
|
model_cls = queryset.model
|
||||||
perms = self.get_required_permissions(request.method, model_cls)
|
perms = self.get_required_permissions(request.method, model_cls)
|
||||||
if (request.user and
|
if (request.user and
|
||||||
request.user.is_authenticated() and
|
request.user.is_authenticated and
|
||||||
request.user.has_perms(perms, model_cls)):
|
request.user.has_perms(perms, model_cls)):
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
@ -22,7 +22,7 @@ class OrchestraPermissionBackend(DjangoModelPermissions):
|
||||||
def has_object_permission(self, request, view, obj):
|
def has_object_permission(self, request, view, obj):
|
||||||
perms = self.get_required_permissions(request.method, type(obj))
|
perms = self.get_required_permissions(request.method, type(obj))
|
||||||
if (request.user and
|
if (request.user and
|
||||||
request.user.is_authenticated() and
|
request.user.is_authenticated and
|
||||||
request.user.has_perms(perms, obj)):
|
request.user.has_perms(perms, obj)):
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
Loading…
Reference in New Issue