Skip to content

Commit

Permalink
Add start date sorting
Browse files Browse the repository at this point in the history
  • Loading branch information
LaurenMullally committed Sep 6, 2023
1 parent 43b7902 commit c14c9ea
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
6 changes: 5 additions & 1 deletion measures/jinja2/includes/measures/list.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@
{{ sort_by(request, "geo_area", "Geographical area", base_url, query_params) }}
{% endset %}

{% set start_date %}
{{ sort_by(request, "start_date", "Start date", base_url, query_params) }}
{% endset %}


{# sets out form #}
<form method="post">
Expand Down Expand Up @@ -85,7 +89,7 @@
{"text": sid},
{"text": measure_type},
{"text": "Commodity"},
{"text": "Start date"},
{"text": start_date},
{"text": "End date"},
{"text": "Duties"},
{"text": "Additional code"},
Expand Down
3 changes: 2 additions & 1 deletion measures/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,11 @@ class MeasureList(
template_name = "measures/list.jinja"
filterset_class = MeasureFilter
form_class = SelectableObjectsForm
sort_by_fields = ["sid", "measure_type", "geo_area"]
sort_by_fields = ["sid", "measure_type", "geo_area", "start_date"]
custom_sorting = {
"measure_type": "measure_type__sid",
"geo_area": "geographical_area__area_id",
"start_date": "valid_between",
}

def dispatch(self, *args, **kwargs):
Expand Down

0 comments on commit c14c9ea

Please sign in to comment.