[Bugfix] 修复创建资产节点的Bug (#3308)

This commit is contained in:
BaiJiangJie
2019-10-08 11:57:22 +08:00
committed by 老广
parent 16d2b0f1f3
commit 90ec6a2962

View File

@@ -25,10 +25,12 @@ class NodeSerializer(BulkOrgResourceModelSerializer):
read_only_fields = ['key', 'org_id'] read_only_fields = ['key', 'org_id']
def validate_value(self, data): def validate_value(self, data):
if not self.instance and not data: if self.instance:
return data
instance = self.instance instance = self.instance
siblings = instance.get_siblings() siblings = instance.get_siblings()
else:
instance = Node.org_root()
siblings = instance.get_children()
if siblings.filter(value=data): if siblings.filter(value=data):
raise serializers.ValidationError( raise serializers.ValidationError(
_('The same level node name cannot be the same') _('The same level node name cannot be the same')