Skip to content

Commit 8743a25

Browse files
authored
Merge pull request #210 from cmu-delphi/us_states_indicatorsets
Moved 'pathogen independent' item to the end of the list, all other p…
2 parents fea2760 + aa6c151 commit 8743a25

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/indicatorsets/forms.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from django import forms
2+
from django.db.models import Case, When, IntegerField
23

34
from base.models import Pathogen, Geography, SeverityPyramidRung
45
from indicatorsets.models import IndicatorSet
@@ -10,7 +11,13 @@ class IndicatorSetFilterForm(forms.ModelForm):
1011
pathogens = forms.ModelMultipleChoiceField(
1112
queryset=Pathogen.objects.filter(
1213
id__in=IndicatorSet.objects.values_list("pathogens", flat=True)
13-
).order_by("display_order_number"),
14+
).annotate(
15+
sort_priority=Case(
16+
When(name__iexact="pathogen independent", then=1),
17+
default=0,
18+
output_field=IntegerField(),
19+
)
20+
).order_by("sort_priority", "name").distinct(),
1421
widget=forms.CheckboxSelectMultiple(),
1522
)
1623

0 commit comments

Comments
 (0)