Skip to content

Commit bbc6da4

Browse files
committed
Removed the redundant "All" option from MultipleDropdownFilter
1 parent ad81ca2 commit bbc6da4

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/unfold/contrib/filters/admin/dropdown_filters.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,19 @@ class DropdownFilter(admin.SimpleListFilter):
2222
all_option = ["", _("All")]
2323

2424
def choices(self, changelist: ChangeList) -> tuple[dict[str, Any], ...]:
25+
choices = []
26+
27+
if self.all_option:
28+
choices = [self.all_option]
29+
30+
choices.extend(self.lookup_choices)
31+
2532
return (
2633
{
2734
"form": self.form_class(
2835
label=_(" By %(filter_title)s ") % {"filter_title": self.title},
2936
name=self.parameter_name,
30-
choices=[self.all_option, *self.lookup_choices],
37+
choices=choices,
3138
data={self.parameter_name: self.value()},
3239
multiple=self.multiple if hasattr(self, "multiple") else False,
3340
),
@@ -37,6 +44,7 @@ def choices(self, changelist: ChangeList) -> tuple[dict[str, Any], ...]:
3744

3845
class MultipleDropdownFilter(DropdownFilter):
3946
multiple = True
47+
all_option = None
4048

4149
def __init__(
4250
self,

0 commit comments

Comments
 (0)