From fa210093091f17b4bb392d42b77dd1df5749da87 Mon Sep 17 00:00:00 2001 From: Raphael Odini Date: Fri, 1 Mar 2024 10:31:57 +0100 Subject: [PATCH] =?UTF-8?q?fix(Admin):=20Besoins:=20ajuste=20les=20r=C3=A8?= =?UTF-8?q?gles=20de=20filtrage=20pour=20le=20montant=20exact.=20ref=20#11?= =?UTF-8?q?12?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lemarche/tenders/admin.py | 6 +++--- lemarche/tenders/tests.py | 6 ++++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/lemarche/tenders/admin.py b/lemarche/tenders/admin.py index 01eaaacd8..909bf02c4 100644 --- a/lemarche/tenders/admin.py +++ b/lemarche/tenders/admin.py @@ -61,7 +61,7 @@ class AmountCustomFilter(admin.SimpleListFilter): def lookups(self, request, model_admin): return ( ("<10k", "Inférieur (<) à 10k €"), - ("5k-10k", "Entre 5k et 10k €"), + ("5k-10k", "Entre (>=) 5k et (<) 10k €"), (">=10k", "Supérieur (>=) à 10k €"), ) @@ -72,8 +72,8 @@ def queryset(self, request, queryset): if value == "<10k": return queryset.filter_by_amount_exact(amount_10k, operation="lt") elif value == "5k-10k": - return queryset.filter_by_amount_exact(amount_10k, operation="lte").filter_by_amount_exact( - amount_5k, operation="gte" + return queryset.filter_by_amount_exact(amount_5k, operation="gte").filter_by_amount_exact( + amount_10k, operation="lt" ) elif value == ">=10k": return queryset.filter_by_amount_exact(amount_10k, operation="gte") diff --git a/lemarche/tenders/tests.py b/lemarche/tenders/tests.py index 75aeee82e..5453ae288 100644 --- a/lemarche/tenders/tests.py +++ b/lemarche/tenders/tests.py @@ -434,6 +434,12 @@ def test_filter_by_amount_exact(self): .count(), 3, ) + self.assertEqual( + tender_qs.filter_by_amount_exact(10000, operation="lt") + .filter_by_amount_exact(5000, operation="gte") + .count(), + 2, + ) class TenderModelQuerysetOrderTest(TestCase):