2023-07-24 03:52:25 +00:00
|
|
|
from django.utils.translation import gettext_lazy as _
|
2023-02-07 05:27:44 +00:00
|
|
|
|
|
|
|
from accounts.models import GatheredAccount
|
|
|
|
from orgs.mixins.serializers import BulkOrgResourceModelSerializer
|
|
|
|
from .account import AccountAssetSerializer
|
|
|
|
from .base import BaseAccountSerializer
|
|
|
|
|
|
|
|
|
2023-02-07 11:45:12 +00:00
|
|
|
class GatheredAccountSerializer(BulkOrgResourceModelSerializer):
|
2023-02-07 05:27:44 +00:00
|
|
|
asset = AccountAssetSerializer(label=_('Asset'))
|
|
|
|
|
|
|
|
class Meta(BaseAccountSerializer.Meta):
|
|
|
|
model = GatheredAccount
|
|
|
|
fields = [
|
2023-02-07 11:45:12 +00:00
|
|
|
'id', 'present', 'asset', 'username',
|
|
|
|
'date_updated', 'address_last_login', 'date_last_login'
|
2023-02-07 05:27:44 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def setup_eager_loading(cls, queryset):
|
|
|
|
""" Perform necessary eager loading of data. """
|
|
|
|
queryset = queryset.prefetch_related('asset', 'asset__platform')
|
|
|
|
return queryset
|