Commit 3ce9d01b authored by ibuler's avatar ibuler

[Bugfix] 修复coco无法查看资产的bug

parent 310bc6ad
...@@ -62,14 +62,15 @@ class UserGrantedAssetsApi(ListAPIView): ...@@ -62,14 +62,15 @@ class UserGrantedAssetsApi(ListAPIView):
""" """
permission_classes = (IsOrgAdminOrAppUser,) permission_classes = (IsOrgAdminOrAppUser,)
serializer_class = AssetGrantedSerializer serializer_class = AssetGrantedSerializer
def dispatch(self, request, *args, **kwargs): def change_org_if_need(self):
if request.user.is_superuser or request.user.is_app or \ if self.request.user.is_superuser or \
self.request.user.is_app or \
self.kwargs.get('pk') is None: self.kwargs.get('pk') is None:
set_to_root_org() set_to_root_org()
return super().dispatch(request, *args, **kwargs)
def get_queryset(self): def get_queryset(self):
self.change_org_if_need()
user_id = self.kwargs.get('pk', '') user_id = self.kwargs.get('pk', '')
queryset = [] queryset = []
...@@ -97,14 +98,15 @@ class UserGrantedNodesApi(ListAPIView): ...@@ -97,14 +98,15 @@ class UserGrantedNodesApi(ListAPIView):
""" """
permission_classes = (IsOrgAdmin,) permission_classes = (IsOrgAdmin,)
serializer_class = NodeSerializer serializer_class = NodeSerializer
def dispatch(self, request, *args, **kwargs): def change_org_if_need(self):
if request.user.is_superuser or request.user.is_app or \ if self.request.user.is_superuser or \
self.request.user.is_app or \
self.kwargs.get('pk') is None: self.kwargs.get('pk') is None:
set_to_root_org() set_to_root_org()
return super().dispatch(request, *args, **kwargs)
def get_queryset(self): def get_queryset(self):
self.change_org_if_need()
user_id = self.kwargs.get('pk', '') user_id = self.kwargs.get('pk', '')
if user_id: if user_id:
user = get_object_or_404(User, id=user_id) user = get_object_or_404(User, id=user_id)
...@@ -126,14 +128,15 @@ class UserGrantedNodesWithAssetsApi(ListAPIView): ...@@ -126,14 +128,15 @@ class UserGrantedNodesWithAssetsApi(ListAPIView):
""" """
permission_classes = (IsOrgAdminOrAppUser,) permission_classes = (IsOrgAdminOrAppUser,)
serializer_class = NodeGrantedSerializer serializer_class = NodeGrantedSerializer
def dispatch(self, request, *args, **kwargs): def change_org_if_need(self):
if request.user.is_superuser or request.user.is_app or \ if self.request.user.is_superuser or \
self.request.user.is_app or \
self.kwargs.get('pk') is None: self.kwargs.get('pk') is None:
set_to_root_org() set_to_root_org()
return super().dispatch(request, *args, **kwargs)
def get_queryset(self): def get_queryset(self):
self.change_org_if_need()
user_id = self.kwargs.get('pk', '') user_id = self.kwargs.get('pk', '')
queryset = [] queryset = []
if not user_id: if not user_id:
...@@ -164,14 +167,15 @@ class UserGrantedNodeAssetsApi(ListAPIView): ...@@ -164,14 +167,15 @@ class UserGrantedNodeAssetsApi(ListAPIView):
""" """
permission_classes = (IsOrgAdminOrAppUser,) permission_classes = (IsOrgAdminOrAppUser,)
serializer_class = AssetGrantedSerializer serializer_class = AssetGrantedSerializer
def dispatch(self, request, *args, **kwargs): def change_org_if_need(self):
if request.user.is_superuser or request.user.is_app or \ if self.request.user.is_superuser or \
self.request.user.is_app or \
self.kwargs.get('pk') is None: self.kwargs.get('pk') is None:
set_to_root_org() set_to_root_org()
return super().dispatch(request, *args, **kwargs)
def get_queryset(self): def get_queryset(self):
self.change_org_if_need()
user_id = self.kwargs.get('pk', '') user_id = self.kwargs.get('pk', '')
node_id = self.kwargs.get('node_id') node_id = self.kwargs.get('node_id')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment