diff --git a/app/access/mixins/permissions.py b/app/access/mixins/permissions.py index 6853e4db5..4c349a1ca 100644 --- a/app/access/mixins/permissions.py +++ b/app/access/mixins/permissions.py @@ -264,6 +264,7 @@ def has_permission(self, request, view): return False + _app_settings: any = None def has_object_permission(self, request, view, obj): @@ -276,11 +277,15 @@ def has_object_permission(self, request, view, obj): object_organization: int = getattr(view.get_obj_organization( obj = obj ), 'id', None) - from settings.models.app_settings import AppSettings + if not self._app_settings: - app_settings = AppSettings.objects.get( - owner_organization = None - ) + from settings.models.app_settings import AppSettings + + app_settings = AppSettings.objects.get( + owner_organization = None + ) + + self._app_settings = app_settings if object_organization: @@ -288,7 +293,7 @@ def has_object_permission(self, request, view, obj): object_organization in view.get_permission_organizations( view.get_permission_required() ) or request.user.is_superuser - or getattr(app_settings.global_organization, 'id', 0) == int(object_organization) + or getattr(self._app_settings.global_organization, 'id', 0) == int(object_organization) ): return True