2022-07-04 10:54:47 +00:00
|
|
|
|
2022-07-15 10:03:32 +00:00
|
|
|
from assets.models import Account
|
2022-07-04 10:54:47 +00:00
|
|
|
from common.drf.serializers import SecretReadableMixin
|
2022-09-23 10:59:19 +00:00
|
|
|
from .base import BaseAccountSerializer
|
2022-07-04 10:54:47 +00:00
|
|
|
from .account import AccountSerializer, AccountSecretSerializer
|
|
|
|
|
|
|
|
|
|
|
|
class AccountHistorySerializer(AccountSerializer):
|
|
|
|
class Meta:
|
2022-07-15 10:03:32 +00:00
|
|
|
model = Account.history.model
|
2022-09-23 10:59:19 +00:00
|
|
|
fields = BaseAccountSerializer.Meta.fields_mini
|
2022-07-04 10:54:47 +00:00
|
|
|
read_only_fields = fields
|
|
|
|
ref_name = 'AccountHistorySerializer'
|
|
|
|
|
|
|
|
def get_field_names(self, declared_fields, info):
|
|
|
|
fields = super().get_field_names(declared_fields, info)
|
|
|
|
fields = list(set(fields) - {'org_name'})
|
|
|
|
return fields
|
|
|
|
|
|
|
|
def to_representation(self, instance):
|
|
|
|
return super(AccountSerializer, self).to_representation(instance)
|
|
|
|
|
|
|
|
|
|
|
|
class AccountHistorySecretSerializer(SecretReadableMixin, AccountHistorySerializer):
|
|
|
|
class Meta(AccountHistorySerializer.Meta):
|
|
|
|
extra_kwargs = AccountSecretSerializer.Meta.extra_kwargs
|