perf: 创建网关 没有关联网域 (#9441)

Co-authored-by: feng <1304903146@qq.com>
pull/9442/head
fit2bot 2023-02-06 14:54:30 +08:00 committed by GitHub
parent f52a2ea47f
commit 654cbe7bd0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 1 deletions

View File

@ -71,7 +71,7 @@ class HostTypes(BaseType):
{'name': 'Linux'},
{
'name': GATEWAY_NAME,
'domain_enabled': False,
'domain_enabled': True,
}
],
cls.UNIX: [

View File

@ -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)