From b6cf0c34f572a3bbdf31ec3f623a5097aebfc425 Mon Sep 17 00:00:00 2001 From: Santiago Lamora Date: Thu, 22 Apr 2021 14:31:05 +0200 Subject: [PATCH] Call User.is_authenticated and User.is_anonymous as properties --- orchestra/api/root.py | 6 +++--- orchestra/permissions/api.py | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/orchestra/api/root.py b/orchestra/api/root.py index 12551571..51fa23c1 100644 --- a/orchestra/api/root.py +++ b/orchestra/api/root.py @@ -11,7 +11,7 @@ class APIRoot(views.APIView): 'ORCHESTRA_SITE_NAME', 'ORCHESTRA_SITE_VERBOSE_NAME' ) - + def get(self, request, format=None): root_url = reverse('api-root', request=request, format=format) token_url = reverse('api-token-auth', request=request, format=format) @@ -23,7 +23,7 @@ class APIRoot(views.APIView): 'accountancy': {}, 'services': {}, } - if not request.user.is_anonymous(): + if not request.user.is_anonymous: list_name = '{basename}-list' detail_name = '{basename}-detail' for prefix, viewset, basename in self.router.registry: @@ -60,7 +60,7 @@ class APIRoot(views.APIView): for name in self.names }) return Response(body, headers=headers) - + def options(self, request): metadata = super(APIRoot, self).options(request) metadata.data['settings'] = { diff --git a/orchestra/permissions/api.py b/orchestra/permissions/api.py index 7f8dc251..5e72aae8 100644 --- a/orchestra/permissions/api.py +++ b/orchestra/permissions/api.py @@ -14,7 +14,7 @@ class OrchestraPermissionBackend(DjangoModelPermissions): model_cls = queryset.model perms = self.get_required_permissions(request.method, model_cls) if (request.user and - request.user.is_authenticated() and + request.user.is_authenticated and request.user.has_perms(perms, model_cls)): return True return False @@ -22,7 +22,7 @@ class OrchestraPermissionBackend(DjangoModelPermissions): def has_object_permission(self, request, view, obj): perms = self.get_required_permissions(request.method, type(obj)) if (request.user and - request.user.is_authenticated() and + request.user.is_authenticated and request.user.has_perms(perms, obj)): return True return False