From 654cbe7bd0911db36c63141553ce07d390db22d2 Mon Sep 17 00:00:00 2001 From: fit2bot <68588906+fit2bot@users.noreply.github.com> Date: Mon, 6 Feb 2023 14:54:30 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E5=88=9B=E5=BB=BA=E7=BD=91=E5=85=B3=20?= =?UTF-8?q?=E6=B2=A1=E6=9C=89=E5=85=B3=E8=81=94=E7=BD=91=E5=9F=9F=20(#9441?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: feng <1304903146@qq.com> --- apps/assets/const/host.py | 2 +- apps/assets/serializers/domain.py | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/apps/assets/const/host.py b/apps/assets/const/host.py index 97233e284..0a5ff60da 100644 --- a/apps/assets/const/host.py +++ b/apps/assets/const/host.py @@ -71,7 +71,7 @@ class HostTypes(BaseType): {'name': 'Linux'}, { 'name': GATEWAY_NAME, - 'domain_enabled': False, + 'domain_enabled': True, } ], cls.UNIX: [ diff --git a/apps/assets/serializers/domain.py b/apps/assets/serializers/domain.py index 33dcffbe1..74eb1117a 100644 --- a/apps/assets/serializers/domain.py +++ b/apps/assets/serializers/domain.py @@ -34,6 +34,13 @@ class DomainSerializer(BulkOrgResourceModelSerializer): data['assets'] = [i for i in assets if str(i['id']) not in gateway_ids] return data + def update(self, instance, validated_data): + assets = validated_data.pop('assets', []) + assets = assets + list(instance.gateways) + validated_data['assets'] = assets + instance = super().update(instance, validated_data) + return instance + class DomainWithGatewaySerializer(serializers.ModelSerializer): gateways = GatewayWithAccountSecretSerializer(many=True, read_only=True)