Skip to content

Commit f4d7f26

Browse files
committed
OKRS24-217 Save stage commit
1 parent cc4b0aa commit f4d7f26

File tree

5 files changed

+52
-104
lines changed

5 files changed

+52
-104
lines changed

src/signals/filters.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
FormatChoices,
1616
Signal,
1717
TimeTypeChoices,
18+
GeographicScope,
1819
)
1920

2021

@@ -45,6 +46,11 @@ class SignalFilter(django_filters.FilterSet):
4546
time_type = django_filters.MultipleChoiceFilter(choices=TimeTypeChoices.choices)
4647
base_signal = django_filters.BooleanFilter(lookup_expr='isnull', field_name='base_for')
4748

49+
def __init__(self, data, *args, **kwargs):
50+
data = data.copy()
51+
data.setdefault('geographic_scope', GeographicScope.objects.get(name='USA').id)
52+
super().__init__(data, *args, **kwargs)
53+
4854
class Meta:
4955
model = Signal
5056
fields: list[str] = [
@@ -55,7 +61,7 @@ class Meta:
5561
'available_geography',
5662
'signal_type',
5763
'category',
58-
'format_type',
64+
'geographic_scope',
5965
'source',
6066
'time_type',
6167
'base_signal',

src/signals/forms.py

+3-14
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
from datasources.models import SourceSubdivision
55
from signals.models import (
66
ActiveChoices,
7-
FormatChoices,
87
Pathogen,
98
Signal,
109
TimeTypeChoices,
10+
GeographicScope,
1111
)
1212

1313

@@ -27,10 +27,10 @@ class SignalFilterForm(forms.ModelForm):
2727
search = forms.CharField(min_length=3)
2828
pathogen = forms.ModelChoiceField(queryset=Pathogen.objects.all(), widget=forms.CheckboxSelectMultiple())
2929
active = forms.TypedMultipleChoiceField(choices=ActiveChoices.choices, coerce=bool, widget=forms.CheckboxSelectMultiple())
30-
format_type = forms.ChoiceField(choices=FormatChoices.choices, widget=forms.CheckboxSelectMultiple())
3130
source = forms.ModelMultipleChoiceField(queryset=SourceSubdivision.objects.all(), widget=forms.CheckboxSelectMultiple())
3231
time_type = forms.ChoiceField(choices=TimeTypeChoices.choices, widget=forms.CheckboxSelectMultiple())
3332
base_signal = forms.ChoiceField(choices=[('', _('All')), (True, _('Yes')), (False, _('No'))], required=False, widget=forms.RadioSelect())
33+
geographic_scope = forms.ModelMultipleChoiceField(queryset=GeographicScope.objects.all(), widget=forms.CheckboxSelectMultiple())
3434

3535
class Meta:
3636
model = Signal
@@ -41,11 +41,10 @@ class Meta:
4141
'pathogen',
4242
'active',
4343
'available_geography',
44-
'category',
45-
'format_type',
4644
'signal_type',
4745
'source',
4846
'time_type',
47+
'geographic_scope',
4948
]
5049

5150
widgets = {
@@ -65,16 +64,6 @@ class Meta:
6564
'data-bs-toggle': 'tooltip',
6665
'data-bs-placement': 'bottom',
6766
}),
68-
'category': forms.CheckboxSelectMultiple(attrs={
69-
'class': 'form-select',
70-
'data-bs-toggle': 'tooltip',
71-
'data-bs-placement': 'bottom',
72-
}),
73-
'format_type': forms.CheckboxSelectMultiple(attrs={
74-
'class': 'form-select',
75-
'data-bs-toggle': 'tooltip',
76-
'data-bs-placement': 'bottom',
77-
}),
7867
'source': forms.CheckboxSelectMultiple(attrs={
7968
'class': 'form-select',
8069
'data-bs-toggle': 'tooltip',

src/signals/models.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,7 @@ class ActiveChoices(models.TextChoices):
5353
"""
5454
A class representing choices for active signals.
5555
"""
56-
ACTIVE = True, _('Active')
57-
HISTORICAL = False, _('Historical')
56+
ACTIVE = True, _('Current Surveillance Only')
5857

5958

6059
class SeverityPyramidRungsChoices(models.TextChoices):

src/signals/views.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
from signals.filters import SignalFilter
1010
from signals.forms import SignalFilterForm
11-
from signals.models import Signal
11+
from signals.models import Signal, GeographicScope
1212
from signals.serializers import SignalSerializer
1313

1414

@@ -48,10 +48,9 @@ def get_url_params(self):
4848
"signal_type": [int(el) for el in self.request.GET.getlist("signal_type")]
4949
if self.request.GET.get("signal_type")
5050
else None,
51-
"category": self.request.GET.getlist("category")
52-
if self.request.GET.get("category")
51+
"geographic_scope": [el for el in self.request.GET.getlist("geographic_scope")]
52+
if self.request.GET.get("geographic_scope")
5353
else None,
54-
"format_type": [el for el in self.request.GET.getlist("format_type")],
5554
"source": [int(el) for el in self.request.GET.getlist("source")],
5655
"time_type": [el for el in self.request.GET.getlist("time_type")],
5756
"base_signal": self.request.GET.get("base_signal"),
@@ -76,6 +75,8 @@ def get_context_data(self, **kwargs) -> Dict[str, Any]:
7675

7776
context: Dict[str, Any] = super().get_context_data(**kwargs)
7877
url_params_dict, url_params_str = self.get_url_params()
78+
if not url_params_dict.get("geographic_scope"):
79+
url_params_dict["geographic_scope"] = [GeographicScope.objects.get(name="USA").id]
7980
context["url_params_dict"] = url_params_dict
8081
context["form"] = SignalFilterForm(initial=url_params_dict)
8182
context["url_params_str"] = url_params_str
@@ -121,9 +122,8 @@ class SignalsListApiView(ListAPIView):
121122
"pathogen__name",
122123
"available_geography__name",
123124
"signal_type__name",
124-
"category__name",
125-
"format_type",
126125
"base",
127126
"source__name",
128127
"time_label",
128+
"geographic_scope__name",
129129
)

0 commit comments

Comments
 (0)