return patch policy when agent requests new updates
@@ -19,17 +19,22 @@ class UpdateSerializer(serializers.ModelSerializer):
"hostname",
"winupdates",
)
+class WinUpdatePolicySerializer(serializers.ModelSerializer):
+
+ class Meta:
+ model = WinUpdatePolicy
+ fields = "__all__"
class ApprovedUpdateSerializer(serializers.ModelSerializer):
winupdates = WinUpdateSerializer(read_only=True)
agentid = serializers.ReadOnlyField(source='agent.pk')
+ patch_policy = serializers.SerializerMethodField('get_policies')
+
+ def get_policies(self, obj):
+ policy = WinUpdatePolicy.objects.get(agent=obj.agent)
+ return WinUpdatePolicySerializer(policy).data
class Meta:
model = WinUpdate
- fields = ("id", "kb", "guid", "agentid", "winupdates",)
+ fields = ("id", "kb", "guid", "agentid", "winupdates", "patch_policy",)
-class WinUpdatePolicySerializer(serializers.ModelSerializer):
-
- class Meta:
- model = WinUpdatePolicy
- fields = "__all__"
\ No newline at end of file
