Skip to content

Commit b6aa998

Browse files
authored
Merge pull request #83 from cmu-delphi/OKRS24-92
OKRS24-92 Change 'Active' filter
2 parents 217c649 + fc0ab5e commit b6aa998

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

src/signals/forms.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
Pathogen,
88
Signal,
99
TimeLabelChoices,
10+
ActiveChoices
1011
)
1112

1213
MULTI_SELECT_TOOLTIP_MESSAGE = _('Hold down “Control”, or “Command” on a Mac, to select more than one.')
@@ -26,7 +27,7 @@ class SignalFilterForm(forms.ModelForm):
2627
)
2728
search = forms.CharField(min_length=3)
2829
pathogen = forms.ModelChoiceField(queryset=Pathogen.objects.all(), empty_label='---------')
29-
active = forms.NullBooleanField(initial=None)
30+
active = forms.TypedMultipleChoiceField(choices=ActiveChoices.choices, coerce=bool, widget=forms.CheckboxSelectMultiple())
3031
format_type = forms.ChoiceField(choices=[('', '---------')] + FormatChoices.choices)
3132
source = forms.ModelChoiceField(queryset=SourceSubdivision.objects.all(), empty_label='---------')
3233
time_label = forms.ChoiceField(choices=[('', '---------')] + TimeLabelChoices.choices, label=_('Temporal Resolution'))
@@ -54,7 +55,6 @@ class Meta:
5455
}),
5556
'search': forms.TextInput(attrs={'class': 'form-control', 'placeholder': 'Enter search term'}),
5657
'pathogen': forms.Select(attrs={'class': 'form-select'}),
57-
'active': forms.NullBooleanSelect(attrs={'class': 'form-check mt-3', 'label': "Test <i class='ri-stack-line'></i>"},),
5858
'available_geography': forms.CheckboxSelectMultiple(attrs={
5959
'class': 'form-select',
6060
'data-bs-toggle': 'tooltip',

src/signals/models.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,14 @@ class HighValuesAreChoices(models.TextChoices):
4141
NEUTRAL = 'neutral', _('Neutral')
4242

4343

44+
class ActiveChoices(models.TextChoices):
45+
"""
46+
A class representing choices for active signals.
47+
"""
48+
ACTIVE = True, _('Active')
49+
HISTORICAL = False, _('Historical')
50+
51+
4452
class SignalCategory(TimeStampedModel):
4553
"""
4654
A model representing a signal category.

src/signals/views.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ def get_url_params(self):
4040
"pathogen": int(self.request.GET.get("pathogen"))
4141
if self.request.GET.get("pathogen")
4242
else "",
43-
"active": self.request.GET.get("active", "unknown"),
43+
"active": [el for el in self.request.GET._getlist("active")]
44+
if self.request.GET.get("active")
45+
else [True, False],
4446
"available_geography": [
4547
int(el) for el in self.request.GET._getlist("available_geography")
4648
]

0 commit comments

Comments
 (0)