return patch policy when agent requests new updates

This commit is contained in:
wh1te909 2019-12-09 05:40:53 +00:00
parent 79ac4336e1
commit beff5d8f12
1 changed files with 15 additions and 10 deletions

View File

@ -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__"
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",)