From 5460bac498865212ef034549f30df4c9a8095c4b Mon Sep 17 00:00:00 2001 From: Matthew Jones Date: Mon, 4 Apr 2016 13:38:17 -0400 Subject: [PATCH] Add historical notifications to notifier summary --- awx/api/serializers.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/awx/api/serializers.py b/awx/api/serializers.py index 490697db5c..91593ad364 100644 --- a/awx/api/serializers.py +++ b/awx/api/serializers.py @@ -2134,6 +2134,14 @@ class NotifierSerializer(BaseSerializer): res['organization'] = reverse('api:organization_detail', args=(obj.organization.pk,)) return res + def _recent_notifications(self, obj): + return [{'id': x.id, 'status': x.status, 'created': x.created} for x in obj.notifications.all().order_by('-created')[:5]] + + def get_summary_fields(self, obj): + d = super(NotifierSerializer, self).get_summary_fields(obj) + d['recent_notifications'] = self._recent_notifications(obj) + return d + def validate(self, attrs): notification_class = Notifier.CLASS_FOR_NOTIFICATION_TYPE[attrs['notification_type']] missing_fields = []