mirror of https://github.com/jumpserver/jumpserver
perf: 修改 accounts
parent
3172e954a8
commit
3145582f0b
|
@ -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
|
||||
|
||||
|
||||
|
|
|
@ -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) """
|
||||
|
|
|
@ -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']
|
||||
|
|
|
@ -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
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue