From 9d2e539fc4c81c105f38c46a8c1d5af91468b477 Mon Sep 17 00:00:00 2001 From: Ohad Lutzky Date: Sun, 18 Jul 2021 00:35:24 +0100 Subject: [PATCH] Consider last-feeding-method as empty if never-changing If the feeding method is always the same, the last-feeding-method card is unhelpful. Consider it "empty" so it can be hidden by user setting. This is an alternative solution to https://github.com/babybuddy/babybuddy/issues/139. --- dashboard/templatetags/cards.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dashboard/templatetags/cards.py b/dashboard/templatetags/cards.py index 3823c504..acd021ab 100644 --- a/dashboard/templatetags/cards.py +++ b/dashboard/templatetags/cards.py @@ -159,7 +159,8 @@ def card_feeding_last_method(context, child): instances = models.Feeding.objects.filter(child=child) \ .filter(**_filter_data_age(context)) \ .order_by('-end')[:3] - empty = len(instances) == 0 + num_unique_methods = len({i.method for i in instances}) + empty = num_unique_methods <= 1 # Results are reversed for carousel forward/back behavior. return {