diff --git a/remo/events/admin.py b/remo/events/admin.py index 1d67217bc..f3158533c 100644 --- a/remo/events/admin.py +++ b/remo/events/admin.py @@ -19,10 +19,11 @@ class EventGoalAdmin(ExportMixin, admin.ModelAdmin): class EventResource(resources.ModelResource): event_goals = fields.Field() event_categories = fields.Field() + event_metrics = fields.Field() class Meta: model = Event - exclude = ('id', 'categories', 'goals',) + exclude = ('id', 'categories', 'goals', 'metrics',) def dehydrate_event_goals(self, event): if event.goals.all().exists(): @@ -36,6 +37,19 @@ def dehydrate_event_categories(self, event): return categories return '' + def dehydrate_event_metrics(self, event): + event_metrics = event.metrics.all() + if event_metrics.exists(): + event_outcome = EventMetricOutcome.objects.filter(event=event) + if event_outcome.exists(): + outcome = [(x.metric.name, x.expected_outcome, x.outcome) + for x in event_outcome] + return str(outcome).strip('[]') + else: + metrics = ', '.join(x.name for x in event_metrics) + return metrics + return '' + class EventAdmin(ExportMixin, admin.ModelAdmin): """Event Admin."""