Merge pull request #2755 from jumpserver/dev_bai

[Update] 修改获取资产信息时返回org_id字段值
pull/2756/head
BaiJiangJie 6 years ago committed by GitHub
commit 63a06b5dd8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -51,7 +51,7 @@ class AssetViewSet(IDInCacheFilterMixin, LabelFilter, BulkModelViewSet):
def set_assets_node(self, assets):
if not isinstance(assets, list):
assets = [assets]
node = Node.objects.get(value='Default')
node = Node.root()
node_id = self.request.query_params.get('node_id')
if node_id:
node = get_object_or_none(Node, pk=node_id)

@ -212,5 +212,7 @@ class OrgResourceSerializerMixin(serializers.Serializer):
"""
通过API批量操作资源时, 自动给每个资源添加所需属性org_id的值为current_org_id
(同时为serializer.is_valid()对Model的unique_together校验做准备)
由于HiddenField字段不可读API获取资产信息时获取不到org_id
但是coco需要资产的org_id字段所以修改为CharField类型
"""
org_id = serializers.HiddenField(default=get_current_org_id)
org_id = serializers.CharField(default=get_current_org_id)

Loading…
Cancel
Save