perf: 修改 platforms

pull/8873/head
ibuler 2022-09-07 20:01:04 +08:00
parent f633a50f8e
commit e9bb5223eb
3 changed files with 3 additions and 7 deletions

View File

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

View File

@ -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. """

View File

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