Skip to content

Commit 9f33614

Browse files
committed
Review comments to consistently use is_rbac_installed
1 parent c9f2700 commit 9f33614

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

ansible_base/authentication/utils/claims.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -960,10 +960,9 @@ def cache_existing(self, role_assignments: Iterable[models.Model]) -> None:
960960
- Role definitions are also cached separately in self.role_definitions
961961
"""
962962
local_resource_prefixes = ["shared"]
963-
if is_rbac_installed():
964-
from ansible_base.rbac.remote import get_local_resource_prefix
963+
from ansible_base.rbac.remote import get_local_resource_prefix # RBAC must be installed to use method
965964

966-
local_resource_prefixes.append(get_local_resource_prefix())
965+
local_resource_prefixes.append(get_local_resource_prefix())
967966

968967
for role_assignment in role_assignments:
969968
# Cache role definition

ansible_base/lib/routers/association_resource_router.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
from itertools import chain
44
from typing import Type
55

6-
from django.conf import settings
76
from django.db.models import Model
87
from django.db.models.fields import IntegerField
98
from django.db.models.query import QuerySet
@@ -17,6 +16,8 @@
1716
from rest_framework.response import Response
1817
from rest_framework.viewsets import ViewSetMixin
1918

19+
from ansible_base.lib.utils.apps import is_rbac_installed
20+
2021
logger = logging.getLogger('ansible_base.lib.routers.association_resource_router')
2122

2223

@@ -117,7 +118,7 @@ def check_parent_object_permissions(self, request, parent_obj: Model) -> None:
117118
will not check "change" permissions to the parent object on POST
118119
this method checks parent change permission, view permission should be handled by filter_queryset
119120
"""
120-
if (request.method not in SAFE_METHODS) and 'ansible_base.rbac' in settings.INSTALLED_APPS:
121+
if (request.method not in SAFE_METHODS) and is_rbac_installed():
121122
from ansible_base.rbac.permission_registry import permission_registry
122123

123124
if permission_registry.is_registered(parent_obj):

0 commit comments

Comments
 (0)