From b0eef2e44c92df01f168dd7f57f6030e25a35545 Mon Sep 17 00:00:00 2001 From: Sander Roosendaal Date: Fri, 7 Oct 2022 08:30:03 +0200 Subject: [PATCH] fix alerts with conditions --- rowers/alerts.py | 2 +- rowers/models.py | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/rowers/alerts.py b/rowers/alerts.py index f1c73fdb..86a1716f 100644 --- a/rowers/alerts.py +++ b/rowers/alerts.py @@ -93,7 +93,7 @@ def alert_get_stats(alert, nperiod=0): # pragma: no cover columns = [alert.measured.metric] for condition in alert.filter.all(): - columns += condition.metric + columns.append(condition.metric) workouts = Workout.objects.filter(date__gte=startdate, date__lte=enddate, user=alert.rower, workouttype=alert.workouttype, duplicate=False, diff --git a/rowers/models.py b/rowers/models.py index 1b50f2a7..2eeefe77 100644 --- a/rowers/models.py +++ b/rowers/models.py @@ -1377,6 +1377,16 @@ class Condition(models.Model): condition = models.CharField( max_length=20, choices=conditionchoices, null=True) + def __str__(self): + str = 'Condition: {metric} {condition} {value1} {value2}'.format( + metric=self.metric, + condition=self.condition, + value1 = self.value1, + value2 = self.value2, + ) + + return str + class ConditionEditForm(ModelForm): class Meta: