diff --git a/apps/orgs/mixins.py b/apps/orgs/mixins.py index 071e70539..4a47f2ee3 100644 --- a/apps/orgs/mixins.py +++ b/apps/orgs/mixins.py @@ -17,7 +17,8 @@ logger = get_logger(__file__) tl = local() __all__ = [ - 'OrgManager', 'OrgViewGenericMixin', 'OrgModelMixin', 'OrgModelForm' + 'OrgManager', 'OrgViewGenericMixin', 'OrgModelMixin', 'OrgModelForm', + 'RootOrgViewMixin', ] diff --git a/apps/perms/api.py b/apps/perms/api.py index dd3c6e9c1..d8691a4c2 100644 --- a/apps/perms/api.py +++ b/apps/perms/api.py @@ -87,7 +87,7 @@ class UserGrantedAssetsApi(ListAPIView): return super().get_permissions() -class UserGrantedNodesApi(ListAPIView): +class UserGrantedNodesApi(RootOrgViewMixin, ListAPIView): permission_classes = (IsOrgAdmin,) serializer_class = NodeSerializer @@ -102,13 +102,12 @@ class UserGrantedNodesApi(ListAPIView): return nodes.keys() def get_permissions(self): - set_current_org(Organization.root()) if self.kwargs.get('pk') is None: self.permission_classes = (IsValidUser,) return super().get_permissions() -class UserGrantedNodesWithAssetsApi(ListAPIView): +class UserGrantedNodesWithAssetsApi(RootOrgViewMixin, ListAPIView): permission_classes = (IsOrgAdminOrAppUser,) serializer_class = NodeGrantedSerializer @@ -132,13 +131,12 @@ class UserGrantedNodesWithAssetsApi(ListAPIView): return queryset def get_permissions(self): - set_current_org(Organization.root()) if self.kwargs.get('pk') is None: self.permission_classes = (IsValidUser,) return super().get_permissions() -class UserGrantedNodeAssetsApi(ListAPIView): +class UserGrantedNodeAssetsApi(RootOrgViewMixin, ListAPIView): permission_classes = (IsOrgAdminOrAppUser,) serializer_class = AssetGrantedSerializer @@ -159,7 +157,6 @@ class UserGrantedNodeAssetsApi(ListAPIView): return assets def get_permissions(self): - set_current_org(Organization.root()) if self.kwargs.get('pk') is None: self.permission_classes = (IsValidUser,) return super().get_permissions()