return patch policy when agent requests new updates
This commit is contained in:
parent
79ac4336e1
commit
beff5d8f12
|
@ -19,17 +19,22 @@ class UpdateSerializer(serializers.ModelSerializer):
|
|||
"hostname",
|
||||
"winupdates",
|
||||
)
|
||||
|
||||
class ApprovedUpdateSerializer(serializers.ModelSerializer):
|
||||
winupdates = WinUpdateSerializer(read_only=True)
|
||||
agentid = serializers.ReadOnlyField(source='agent.pk')
|
||||
|
||||
class Meta:
|
||||
model = WinUpdate
|
||||
fields = ("id", "kb", "guid", "agentid", "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", "patch_policy",)
|
||||
|
||||
|
|
Loading…
Reference in New Issue