|
|
|
@ -136,6 +136,7 @@ class AssetSerializer(BulkOrgResourceModelSerializer, WritableNestedModelSeriali
|
|
|
|
|
read_only_fields = [
|
|
|
|
|
'category', 'type', 'connectivity',
|
|
|
|
|
'date_verified', 'created_by', 'date_created',
|
|
|
|
|
'auto_info',
|
|
|
|
|
]
|
|
|
|
|
fields = fields_small + fields_fk + fields_m2m + read_only_fields
|
|
|
|
|
extra_kwargs = {
|
|
|
|
@ -182,10 +183,10 @@ class AssetSerializer(BulkOrgResourceModelSerializer, WritableNestedModelSeriali
|
|
|
|
|
@classmethod
|
|
|
|
|
def setup_eager_loading(cls, queryset):
|
|
|
|
|
""" Perform necessary eager loading of data. """
|
|
|
|
|
queryset = queryset.prefetch_related('domain', 'platform') \
|
|
|
|
|
queryset = queryset.prefetch_related('domain', 'nodes', 'labels', 'protocols') \
|
|
|
|
|
.prefetch_related('platform', 'platform__automation') \
|
|
|
|
|
.annotate(category=F("platform__category")) \
|
|
|
|
|
.annotate(type=F("platform__type"))
|
|
|
|
|
queryset = queryset.prefetch_related('nodes', 'labels', 'protocols')
|
|
|
|
|
return queryset
|
|
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
|