jumpserver/apps/assets/serializers/account/base.py

28 lines
963 B
Python
Raw Normal View History

2022-09-23 10:59:19 +00:00
# -*- coding: utf-8 -*-
from django.utils.translation import gettext_lazy as _
from assets.models import BaseAccount
from assets.serializers.base import AuthValidateMixin
from orgs.mixins.serializers import BulkOrgResourceModelSerializer
2022-09-23 10:59:19 +00:00
__all__ = ['BaseAccountSerializer']
class BaseAccountSerializer(AuthValidateMixin, BulkOrgResourceModelSerializer):
2022-09-23 10:59:19 +00:00
class Meta:
model = BaseAccount
fields_mini = ['id', 'name', 'username']
fields_small = fields_mini + [
'secret_type', 'secret', 'has_secret', 'passphrase',
'privileged', 'is_active', 'specific',
]
2022-09-23 10:59:19 +00:00
fields_other = ['created_by', 'date_created', 'date_updated', 'comment']
fields = fields_small + fields_other
2022-11-03 04:42:57 +00:00
read_only_fields = [
'has_secret', 'specific',
'date_verified', 'created_by', 'date_created',
]
2022-09-23 10:59:19 +00:00
extra_kwargs = {
2022-11-04 12:14:19 +00:00
'specific': {'label': _('Specific')},
2022-09-23 10:59:19 +00:00
}