perf: 修改 accounts

pull/9246/head
ibuler 2022-12-26 18:58:21 +08:00
parent 3172e954a8
commit 3145582f0b
4 changed files with 8 additions and 4 deletions

View File

@ -1,9 +1,6 @@
from assets import serializers
from assets.models import AccountTemplate
from rbac.permissions import RBACPermission
from authentication.const import ConfirmType
from common.mixins import RecordViewLogMixin
from common.permissions import UserConfirmation
from orgs.mixins.api import OrgBulkModelViewSet

View File

@ -82,6 +82,10 @@ class Account(AbsConnectivity, BaseAccount):
def __str__(self):
return '{}'.format(self.username)
@lazyproperty
def has_secret(self):
return bool(self.secret)
@classmethod
def get_manual_account(cls):
""" @INPUT 手动登录的账号(any) """

View File

@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-
from django.utils.translation import gettext_lazy as _
from rest_framework import serializers
from assets.models import BaseAccount
from assets.serializers.base import AuthValidateMixin
@ -9,6 +10,8 @@ __all__ = ['BaseAccountSerializer']
class BaseAccountSerializer(AuthValidateMixin, BulkOrgResourceModelSerializer):
has_secret = serializers.BooleanField(label=_("Has secret"), read_only=True)
class Meta:
model = BaseAccount
fields_mini = ['id', 'name', 'username']

View File

@ -1,5 +1,5 @@
from common.drf.serializers import SecretReadableMixin
from assets.models import AccountTemplate
from common.drf.serializers import SecretReadableMixin
from .base import BaseAccountSerializer