Skip to content

Commit 32879df

Browse files
committed
OKRS24-217 Updated filters.
1 parent f4d7f26 commit 32879df

File tree

8 files changed

+53
-22
lines changed

8 files changed

+53
-22
lines changed

src/datasources/admin.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class SourceSubdivisionAdmin(ImportExportModelAdmin):
1212
"""
1313
Admin interface for managing source subdivision objects.
1414
"""
15-
list_display: tuple[Literal['name'], Literal['db_source']] = ('name', 'db_source')
15+
list_display: tuple[Literal['name'], Literal['db_source'], Literal['external_name']] = ('name', 'db_source', 'external_name')
1616
search_fields: tuple[Literal['name'], Literal['db_source']] = ('name', 'db_source')
1717
resource_classes: list[type[SourceSubdivisionResource]] = [SourceSubdivisionResource]
1818

src/fixtures/available_geography.json

+7
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"pk": 1,
55
"fields": {
66
"name": "county",
7+
"display_name": "L2 division (e.g. U.S. counties)",
78
"created": "2023-08-09T19:23:22.597131",
89
"modified": "2023-08-09T19:23:22.597131"
910
}
@@ -13,6 +14,7 @@
1314
"pk": 2,
1415
"fields": {
1516
"name": "hhs",
17+
"display_name": "HHS Regions",
1618
"created": "2023-08-09T19:23:22.597131",
1719
"modified": "2023-08-09T19:23:22.597131"
1820
}
@@ -22,6 +24,7 @@
2224
"pk": 3,
2325
"fields": {
2426
"name": "hrr",
27+
"display_name": "Hospital Referral Regions (HRAs)",
2528
"created": "2023-08-09T19:23:22.597131",
2629
"modified": "2023-08-09T19:23:22.597131"
2730
}
@@ -31,6 +34,7 @@
3134
"pk": 4,
3235
"fields": {
3336
"name": "msa",
37+
"display_name": "Metropolitan Statistical Areas (MSAs)",
3438
"created": "2023-08-09T19:23:22.597131",
3539
"modified": "2023-08-09T19:23:22.597131"
3640
}
@@ -40,6 +44,7 @@
4044
"pk": 5,
4145
"fields": {
4246
"name": "nation",
47+
"display_name": "National",
4348
"created": "2023-08-09T19:23:22.597131",
4449
"modified": "2023-08-09T19:23:22.597131"
4550
}
@@ -49,6 +54,7 @@
4954
"pk": 6,
5055
"fields": {
5156
"name": "state",
57+
"display_name": "L1 division (e.g. U.S. states)",
5258
"created": "2023-08-09T19:23:22.597131",
5359
"modified": "2023-08-09T19:23:22.597131"
5460
}
@@ -58,6 +64,7 @@
5864
"pk": 7,
5965
"fields": {
6066
"name": "dma",
67+
"display_name": "Designated Market Areas (DMAs)",
6168
"created": "2023-08-09T19:23:22.597131",
6269
"modified": "2023-08-09T19:23:22.597131"
6370
}

src/signals/filters.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
Signal,
1717
TimeTypeChoices,
1818
GeographicScope,
19+
SeverityPyramidRungsChoices,
1920
)
2021

2122

@@ -42,6 +43,7 @@ class SignalFilter(django_filters.FilterSet):
4243
)
4344
)
4445
format_type = django_filters.MultipleChoiceFilter(choices=FormatChoices.choices)
46+
severenity_pyramid_rungs = django_filters.MultipleChoiceFilter(choices=SeverityPyramidRungsChoices.choices)
4547
source = django_filters.ModelMultipleChoiceFilter(queryset=SourceSubdivision.objects.all())
4648
time_type = django_filters.MultipleChoiceFilter(choices=TimeTypeChoices.choices)
4749
base_signal = django_filters.BooleanFilter(lookup_expr='isnull', field_name='base_for')
@@ -59,7 +61,7 @@ class Meta:
5961
'pathogen',
6062
'active',
6163
'available_geography',
62-
'signal_type',
64+
'severenity_pyramid_rungs',
6365
'category',
6466
'geographic_scope',
6567
'source',

src/signals/forms.py

+3-6
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
Signal,
99
TimeTypeChoices,
1010
GeographicScope,
11+
SeverityPyramidRungsChoices,
1112
)
1213

1314

@@ -31,6 +32,7 @@ class SignalFilterForm(forms.ModelForm):
3132
time_type = forms.ChoiceField(choices=TimeTypeChoices.choices, widget=forms.CheckboxSelectMultiple())
3233
base_signal = forms.ChoiceField(choices=[('', _('All')), (True, _('Yes')), (False, _('No'))], required=False, widget=forms.RadioSelect())
3334
geographic_scope = forms.ModelMultipleChoiceField(queryset=GeographicScope.objects.all(), widget=forms.CheckboxSelectMultiple())
35+
severenity_pyramid_rungs = forms.ChoiceField(choices=SeverityPyramidRungsChoices.choices, widget=forms.CheckboxSelectMultiple())
3436

3537
class Meta:
3638
model = Signal
@@ -41,7 +43,7 @@ class Meta:
4143
'pathogen',
4244
'active',
4345
'available_geography',
44-
'signal_type',
46+
'severenity_pyramid_rungs',
4547
'source',
4648
'time_type',
4749
'geographic_scope',
@@ -59,11 +61,6 @@ class Meta:
5961
'data-bs-toggle': 'tooltip',
6062
'data-bs-placement': 'bottom',
6163
}),
62-
'signal_type': forms.CheckboxSelectMultiple(attrs={
63-
'class': 'form-select',
64-
'data-bs-toggle': 'tooltip',
65-
'data-bs-placement': 'bottom',
66-
}),
6764
'source': forms.CheckboxSelectMultiple(attrs={
6865
'class': 'form-select',
6966
'data-bs-toggle': 'tooltip',
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Generated by Django 4.2.10 on 2024-06-11 14:17
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('signals', '0016_remove_signal_geographic_scope_and_more'),
10+
]
11+
12+
operations = [
13+
migrations.AddField(
14+
model_name='geography',
15+
name='display_name',
16+
field=models.CharField(blank=True, help_text='Display Name', max_length=128, null=True),
17+
),
18+
]

src/signals/models.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,13 @@ class Geography(TimeStampedModel):
153153
unique=True
154154
)
155155

156+
display_name: models.CharField = models.CharField(
157+
help_text=_('Display Name'),
158+
max_length=128,
159+
null=True,
160+
blank=True
161+
)
162+
156163
class Meta:
157164
verbose_name_plural: str = "geographies"
158165
ordering: list[str] = ["name"]
@@ -164,7 +171,7 @@ def __str__(self) -> str:
164171
:return: The name of the available geography as a string.
165172
:rtype: str
166173
"""
167-
return str(self.name)
174+
return str(self.display_name)
168175

169176

170177
class GeographySignal(models.Model):

src/signals/views.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ def get_url_params(self):
4545
]
4646
if self.request.GET.get("available_geography")
4747
else None,
48-
"signal_type": [int(el) for el in self.request.GET.getlist("signal_type")]
49-
if self.request.GET.get("signal_type")
48+
"severenity_pyramid_rungs": [el for el in self.request.GET.getlist("severenity_pyramid_rungs")]
49+
if self.request.GET.get("severenity_pyramid_rungs")
5050
else None,
5151
"geographic_scope": [el for el in self.request.GET.getlist("geographic_scope")]
5252
if self.request.GET.get("geographic_scope")
@@ -121,7 +121,7 @@ class SignalsListApiView(ListAPIView):
121121
"display_name",
122122
"pathogen__name",
123123
"available_geography__name",
124-
"signal_type__name",
124+
"severenity_pyramid_rungs",
125125
"base",
126126
"source__name",
127127
"time_label",

src/templates/signals/signals.html

+10-10
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,10 @@ <h2 class="accordion-header" id="active-heading">
8585
</div>
8686
</div>
8787
<div class="accordion-item">
88-
<h2 class="accordion-header" id="severity_pyramid-heading">
88+
<h2 class="accordion-header" id="severenity_pyramid_rungs-heading">
8989
<button class="accordion-button collapsed" type="button" data-bs-toggle="collapse"
90-
data-bs-target="#severity_pyramid-collapse" aria-expanded="false" aria-controls="active-collapse">
91-
<label for="id_severity_pyramid" class="form-label">
90+
data-bs-target="#severenity_pyramid_rungs-collapse" aria-expanded="false" aria-controls="active-collapse">
91+
<label for="id_severenity_pyramid_rungs" class="form-label">
9292
Severity Pyramid
9393
<a tabindex="0" role="button" class="info-button" data-bs-toggle="popover"
9494
data-bs-title="Severity Pyramid"
@@ -98,17 +98,17 @@ <h2 class="accordion-header" id="severity_pyramid-heading">
9898
</label>
9999
</button>
100100
</h2>
101-
{% if form.signal_type.value %}
102-
<div id="signal_type-collapse" class="accordion-collapse" aria-labelledby="signal_type-heading">
101+
{% if form.severenity_pyramid_rungs.value %}
102+
<div id="severenity_pyramid_rungs-collapse" class="accordion-collapse" aria-labelledby="severenity_pyramid_rungs-heading">
103103
{% else %}
104-
<div id="signal_type-collapse" class="accordion-collapse collapse" aria-labelledby="signal_type-heading">
104+
<div id="severenity_pyramid_rungs-collapse" class="accordion-collapse collapse" aria-labelledby="severenity_pyramid_rungs-heading">
105105
{% endif %}
106106
<div class="accordion-body">
107107
<div class="bulk-select form-check">
108108
<input type="checkbox" class="form-check-input" id="select-all">
109109
<label class="form-check-label" for="select-all">Select all</label>
110110
</div>
111-
{{ form.signal_type|as_crispy_field }}
111+
{{ form.severenity_pyramid_rungs|as_crispy_field }}
112112
</div>
113113
</div>
114114
</div>
@@ -142,7 +142,7 @@ <h2 class="accordion-header" id="source-heading">
142142
<button class="accordion-button collapsed" type="button" data-bs-toggle="collapse"
143143
data-bs-target="#source-collapse" aria-expanded="false" aria-controls="active-collapse">
144144
<label for="id_source" class="form-label">
145-
Source
145+
Data Source
146146
<a tabindex="0" role="button" class="info-button" data-bs-toggle="popover"
147147
data-bs-title="Source"
148148
data-bs-content="{{ filters_descriptions.SignalFilter.source }}">
@@ -170,9 +170,9 @@ <h2 class="accordion-header" id="time_type-heading">
170170
<button class="accordion-button collapsed" type="button" data-bs-toggle="collapse"
171171
data-bs-target="#time_type-collapse" aria-expanded="false" aria-controls="active-collapse">
172172
<label for="id_time_type" class="form-label">
173-
Time Type
173+
Temporal Granularity
174174
<a tabindex="0" role="button" class="info-button" data-bs-toggle="popover"
175-
data-bs-title="Time Label"
175+
data-bs-title="Temporal Granularity"
176176
data-bs-content="{{ filters_descriptions.SignalFilter.time_type }}">
177177
<i class="bi bi-info-circle"></i>
178178
</a>

0 commit comments

Comments
 (0)