Skip to content

Commit

Permalink
fix(Admin): Besoins: ajuste les règles de filtrage pour le montant ex…
Browse files Browse the repository at this point in the history
…act. ref #1112
  • Loading branch information
raphodn committed Mar 1, 2024
1 parent df3fd2f commit fa21009
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lemarche/tenders/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 €"),
)

Expand All @@ -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")
Expand Down
6 changes: 6 additions & 0 deletions lemarche/tenders/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit fa21009

Please sign in to comment.