diff --git a/atlas/filters.py b/atlas/filters.py index 8763221c..0834c815 100755 --- a/atlas/filters.py +++ b/atlas/filters.py @@ -450,7 +450,7 @@ class NormalCaseFilter(django_filters.FilterSet): ("months", "Months"), ("years", "Years"), ) - age_unit = django_filters.ChoiceFilter(label="Unit", choices=AGE_UNIT_CHOICES) + age_unit = django_filters.ChoiceFilter(label="Unit", choices=AGE_UNIT_CHOICES, method="filter_age_unit") class Meta: model = NormalCase @@ -554,9 +554,9 @@ class NormalCaseFilter(django_filters.FilterSet): def filter_min_value(self, queryset, name, value): try: - unit = getattr(self.form, "cleaned_data", {}).get("age_unit", "years") + unit = getattr(self.form, "cleaned_data", {}).get("age_unit", "days") except Exception: - unit = "years" + unit = "days" try: days = self._convert_to_days(value, unit) except Exception: @@ -565,15 +565,20 @@ class NormalCaseFilter(django_filters.FilterSet): def filter_max_value(self, queryset, name, value): try: - unit = getattr(self.form, "cleaned_data", {}).get("age_unit", "years") + unit = getattr(self.form, "cleaned_data", {}).get("age_unit", "days") except Exception: - unit = "years" + unit = "days" try: days = self._convert_to_days(value, unit) except Exception: return queryset return queryset.filter(age_days__lte=days) + def filter_age_unit(self, queryset, name, value): + # `age_unit` is a helper input used by min/max conversion and does not + # map to a database field on NormalCase. + return queryset + class ResourceFilter(django_filters.FilterSet): name = django_filters.CharFilter(field_name='name', lookup_expr='icontains') diff --git a/atlas/templates/atlas/user_uploads.html b/atlas/templates/atlas/user_uploads.html index d94a6cb9..e79ab319 100644 --- a/atlas/templates/atlas/user_uploads.html +++ b/atlas/templates/atlas/user_uploads.html @@ -29,7 +29,7 @@