From b38521db690b3278f52f6de96fafc443fc046b45 Mon Sep 17 00:00:00 2001 From: Gabriel Detraz Date: Tue, 24 Sep 2019 01:04:38 +0200 Subject: [PATCH] For my klafy : return best mandate possible --- preferences/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/preferences/models.py b/preferences/models.py index ab2aa29c..f09e63a7 100644 --- a/preferences/models.py +++ b/preferences/models.py @@ -531,7 +531,7 @@ class Mandate(RevMixin, AclMixin, models.Model): """"Find the mandate taking place at the given date.""" if callable(date): date = date() - mandate = cls.objects.filter(start_date__lte=date).order_by('-start_date').first() + mandate = cls.objects.exclude(end_date__lte=date).order_by('start_date').first() or cls.objects.order_by('start_date').last() if not mandate: raise cls.DoesNotExist("No mandate have been created. Please go to the preferences page to create one.") return mandate