From e9bb5223ebc51d39b97d02f186285dc54d9c36ff Mon Sep 17 00:00:00 2001 From: ibuler Date: Wed, 7 Sep 2022 20:01:04 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E4=BF=AE=E6=94=B9=20platforms?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/assets/models/account.py | 2 +- apps/assets/serializers/asset/common.py | 7 +------ apps/assets/serializers/platform.py | 1 + 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/apps/assets/models/account.py b/apps/assets/models/account.py index 6f122cfe2..7b9e543a2 100644 --- a/apps/assets/models/account.py +++ b/apps/assets/models/account.py @@ -10,7 +10,7 @@ __all__ = ['Account', 'AccountTemplate'] class Account(BaseAccount): - asset = models.ForeignKey('assets.Asset', on_delete=models.CASCADE, verbose_name=_('Asset')) + asset = models.ForeignKey('assets.Asset', related_name='accounts', on_delete=models.CASCADE, verbose_name=_('Asset')) version = models.IntegerField(default=0, verbose_name=_('Version')) history = HistoricalRecords() diff --git a/apps/assets/serializers/asset/common.py b/apps/assets/serializers/asset/common.py index 61e32a7a8..f55a73c3d 100644 --- a/apps/assets/serializers/asset/common.py +++ b/apps/assets/serializers/asset/common.py @@ -8,7 +8,7 @@ from django.db.models import F from common.drf.serializers import JMSWritableNestedModelSerializer from common.drf.fields import LabeledChoiceField, ObjectRelatedField from ..account import AccountSerializer -from ...models import Asset, Node, Platform, Protocol, Label, Domain +from ...models import Asset, Node, Platform, Protocol, Label, Domain, Account from ...const import Category, AllTypes __all__ = [ @@ -88,11 +88,6 @@ class AssetSerializer(JMSWritableNestedModelSerializer): 'admin_user_display': {'label': _('Admin user display'), 'read_only': True}, } - def __init__(self, *args, **kwargs): - data = kwargs.get('data', {}) - self.accounts_data = data.pop('accounts', []) - super().__init__(*args, **kwargs) - @classmethod def setup_eager_loading(cls, queryset): """ Perform necessary eager loading of data. """ diff --git a/apps/assets/serializers/platform.py b/apps/assets/serializers/platform.py index 01f2e8956..600098b86 100644 --- a/apps/assets/serializers/platform.py +++ b/apps/assets/serializers/platform.py @@ -19,6 +19,7 @@ class ProtocolSettingSerializer(serializers.Serializer): ] # Common required = serializers.BooleanField(required=True, initial=False, label=_("Required")) + # RDP console = serializers.BooleanField(required=False) security = serializers.ChoiceField(choices=SECURITY_CHOICES, default='any', required=False)