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):