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

31 lines
1.1 KiB
Python
Raw Normal View History

2022-09-23 10:59:19 +00:00
# -*- coding: utf-8 -*-
from django.utils.translation import gettext_lazy as _
2022-12-26 10:58:21 +00:00
from rest_framework import serializers
2022-09-23 10:59:19 +00:00
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-12-26 10:58:21 +00:00
has_secret = serializers.BooleanField(label=_("Has secret"), read_only=True)
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
}