[Update] Merge with org

pull/1644/head
ibuler 2018-07-27 16:19:19 +08:00
parent 9166a26f80
commit d3dca5d077
2 changed files with 5 additions and 7 deletions

View File

@ -17,7 +17,8 @@ logger = get_logger(__file__)
tl = local()
__all__ = [
'OrgManager', 'OrgViewGenericMixin', 'OrgModelMixin', 'OrgModelForm'
'OrgManager', 'OrgViewGenericMixin', 'OrgModelMixin', 'OrgModelForm',
'RootOrgViewMixin',
]

View File

@ -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()