Browse Source

perf: 修改默认节点

pull/10235/head
ibuler 2 years ago
parent
commit
5921b2ee8f
  1. 2
      apps/accounts/serializers/account/account.py
  2. 5
      apps/assets/serializers/asset/common.py

2
apps/accounts/serializers/account/account.py

@ -59,7 +59,7 @@ class AccountCreateUpdateSerializerMixin(serializers.Serializer):
def set_uniq_name_if_need(self, initial_data, asset):
name = initial_data.get('name')
if name is None:
if name is not None:
return
if not name:
name = initial_data.get('username')

5
apps/assets/serializers/asset/common.py

@ -267,12 +267,13 @@ class AssetSerializer(BulkOrgResourceModelSerializer, WritableNestedModelSeriali
nodes_display = self.initial_data.get('nodes_display')
if nodes_display:
return nodes
default_node = Node.org_root()
request = self.context.get('request')
if not request:
return []
return [default_node]
node_id = request.query_params.get('node_id')
if not node_id:
return []
return [default_node]
nodes = Node.objects.filter(id=node_id)
return nodes

Loading…
Cancel
Save