Skip to content

Commit fcac7a8

Browse files
committed
Added Geo-Level ordering in filters list
1 parent 55a9c08 commit fcac7a8

File tree

4 files changed

+33
-0
lines changed

4 files changed

+33
-0
lines changed

src/fixtures/available_geography.json

+7
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"fields": {
66
"name": "county",
77
"display_name": "ADM2 (e.g. U.S. counties)",
8+
"order_id": 3,
89
"created": "2023-08-09T19:23:22.597131",
910
"modified": "2023-08-09T19:23:22.597131"
1011
}
@@ -15,6 +16,7 @@
1516
"fields": {
1617
"name": "hhs",
1718
"display_name": "HHS Regions",
19+
"order_id": 4,
1820
"created": "2023-08-09T19:23:22.597131",
1921
"modified": "2023-08-09T19:23:22.597131"
2022
}
@@ -25,6 +27,7 @@
2527
"fields": {
2628
"name": "hrr",
2729
"display_name": "Hospital Referral Regions (HRRs)",
30+
"order_id": 6,
2831
"created": "2023-08-09T19:23:22.597131",
2932
"modified": "2023-08-09T19:23:22.597131"
3033
}
@@ -35,6 +38,7 @@
3538
"fields": {
3639
"name": "msa",
3740
"display_name": "Metropolitan Statistical Areas (MSAs)",
41+
"order_id": 5,
3842
"created": "2023-08-09T19:23:22.597131",
3943
"modified": "2023-08-09T19:23:22.597131"
4044
}
@@ -45,6 +49,7 @@
4549
"fields": {
4650
"name": "nation",
4751
"display_name": "National",
52+
"order_id": 1,
4853
"created": "2023-08-09T19:23:22.597131",
4954
"modified": "2023-08-09T19:23:22.597131"
5055
}
@@ -55,6 +60,7 @@
5560
"fields": {
5661
"name": "state",
5762
"display_name": "ADM1 (e.g. U.S. states)",
63+
"order_id": 2,
5864
"created": "2023-08-09T19:23:22.597131",
5965
"modified": "2023-08-09T19:23:22.597131"
6066
}
@@ -65,6 +71,7 @@
6571
"fields": {
6672
"name": "dma",
6773
"display_name": "Designated Market Areas (DMAs)",
74+
"order_id": 7,
6875
"created": "2023-08-09T19:23:22.597131",
6976
"modified": "2023-08-09T19:23:22.597131"
7077
}

src/signals/forms.py

+2
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,5 @@ def __init__(self, *args, **kwargs) -> None:
7979
field.required = False
8080
field.help_text = ''
8181
field.label = ''
82+
if field_name == "available_geography":
83+
field.queryset = field.queryset.order_by("order_id")
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Generated by Django 4.2.10 on 2024-06-11 18:47
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('signals', '0017_geography_display_name'),
10+
]
11+
12+
operations = [
13+
migrations.AddField(
14+
model_name='geography',
15+
name='order_id',
16+
field=models.IntegerField(blank=True, help_text='Order ID', null=True),
17+
),
18+
]

src/signals/models.py

+6
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,12 @@ class Geography(TimeStampedModel):
160160
blank=True
161161
)
162162

163+
order_id: models.IntegerField = models.IntegerField(
164+
help_text=_('Order ID'),
165+
null=True,
166+
blank=True
167+
)
168+
163169
class Meta:
164170
verbose_name_plural: str = "geographies"
165171
ordering: list[str] = ["name"]

0 commit comments

Comments
 (0)