Skip to content

OKRS24-92 Change 'Active' filter #83

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/signals/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
Pathogen,
Signal,
TimeLabelChoices,
ActiveChoices
)

MULTI_SELECT_TOOLTIP_MESSAGE = _('Hold down “Control”, or “Command” on a Mac, to select more than one.')
Expand All @@ -26,7 +27,7 @@ class SignalFilterForm(forms.ModelForm):
)
search = forms.CharField(min_length=3)
pathogen = forms.ModelChoiceField(queryset=Pathogen.objects.all(), empty_label='---------')
active = forms.NullBooleanField(initial=None)
active = forms.TypedMultipleChoiceField(choices=ActiveChoices.choices, coerce=bool, widget=forms.CheckboxSelectMultiple())
format_type = forms.ChoiceField(choices=[('', '---------')] + FormatChoices.choices)
source = forms.ModelChoiceField(queryset=SourceSubdivision.objects.all(), empty_label='---------')
time_label = forms.ChoiceField(choices=[('', '---------')] + TimeLabelChoices.choices, label=_('Temporal Resolution'))
Expand Down Expand Up @@ -54,7 +55,6 @@ class Meta:
}),
'search': forms.TextInput(attrs={'class': 'form-control', 'placeholder': 'Enter search term'}),
'pathogen': forms.Select(attrs={'class': 'form-select'}),
'active': forms.NullBooleanSelect(attrs={'class': 'form-check mt-3', 'label': "Test <i class='ri-stack-line'></i>"},),
'available_geography': forms.CheckboxSelectMultiple(attrs={
'class': 'form-select',
'data-bs-toggle': 'tooltip',
Expand Down
8 changes: 8 additions & 0 deletions src/signals/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ class HighValuesAreChoices(models.TextChoices):
NEUTRAL = 'neutral', _('Neutral')


class ActiveChoices(models.TextChoices):
"""
A class representing choices for active signals.
"""
ACTIVE = True, _('Active')
HISTORICAL = False, _('Historical')


class SignalCategory(TimeStampedModel):
"""
A model representing a signal category.
Expand Down
4 changes: 3 additions & 1 deletion src/signals/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ def get_url_params(self):
"pathogen": int(self.request.GET.get("pathogen"))
if self.request.GET.get("pathogen")
else "",
"active": self.request.GET.get("active", "unknown"),
"active": [el for el in self.request.GET._getlist("active")]
if self.request.GET.get("active")
else [True, False],
"available_geography": [
int(el) for el in self.request.GET._getlist("available_geography")
]
Expand Down