2022-09-23 10:59:19 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
from django.utils.translation import gettext_lazy as _
|
|
|
|
|
|
|
|
from assets.models import BaseAccount
|
2022-11-09 10:15:21 +00:00
|
|
|
from assets.serializers.base import AuthValidateMixin
|
|
|
|
from orgs.mixins.serializers import BulkOrgResourceModelSerializer
|
2022-09-23 10:59:19 +00:00
|
|
|
|
|
|
|
__all__ = ['BaseAccountSerializer']
|
|
|
|
|
|
|
|
|
2022-11-09 10:15:21 +00:00
|
|
|
class BaseAccountSerializer(AuthValidateMixin, BulkOrgResourceModelSerializer):
|
2022-09-23 10:59:19 +00:00
|
|
|
class Meta:
|
|
|
|
model = BaseAccount
|
|
|
|
fields_mini = ['id', 'name', 'username']
|
2022-11-08 11:18:04 +00:00
|
|
|
fields_small = fields_mini + [
|
2022-11-09 10:15:21 +00:00
|
|
|
'secret_type', 'secret', 'has_secret', 'passphrase',
|
2022-11-08 11:18:04 +00:00
|
|
|
'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
|
|
|
}
|