Merge pull request #1468 from jpros/add-custom-fields-to-agents-route

Added agent's custom fields to table result
This commit is contained in:
Dan 2023-04-03 22:30:20 -07:00 committed by GitHub
commit c934065f8e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 0 deletions

View File

@ -95,6 +95,7 @@ class AgentTableSerializer(serializers.ModelSerializer):
local_ips = serializers.ReadOnlyField()
make_model = serializers.ReadOnlyField()
physical_disks = serializers.ReadOnlyField()
custom_fields = AgentCustomFieldSerializer(many=True, read_only=True)
def get_alert_template(self, obj):
if not obj.alert_template:
@ -153,6 +154,7 @@ class AgentTableSerializer(serializers.ModelSerializer):
"local_ips",
"make_model",
"physical_disks",
"custom_fields",
]
depth = 2

View File

@ -134,6 +134,10 @@ class GetAgents(APIView):
"checkresults",
queryset=CheckResult.objects.select_related("assigned_check"),
),
Prefetch(
"custom_fields",
queryset=AgentCustomField.objects.select_related("field"),
),
)
.annotate(
has_patches_pending=Exists(