From 7231576a6e8b16d1914a90914bf37f2d0fe8f6bb Mon Sep 17 00:00:00 2001 From: tdruez Date: Tue, 27 Aug 2024 18:24:45 +0400 Subject: [PATCH] Add sorting dropdown in the list #95 Signed-off-by: tdruez --- component_catalog/filters.py | 1 - .../templates/component_catalog/vulnerability_list.html | 7 +++++++ component_catalog/views.py | 3 ++- .../includes => dje/templates/modals}/filterset_modal.html | 6 +++--- purldb/templates/purldb/purldb_list.html | 4 ++-- purldb/tests/test_views.py | 4 ++-- purldb/views.py | 4 ++-- 7 files changed, 18 insertions(+), 11 deletions(-) rename {purldb/templates/purldb/includes => dje/templates/modals}/filterset_modal.html (72%) diff --git a/component_catalog/filters.py b/component_catalog/filters.py index 360c2146..a3a727dd 100644 --- a/component_catalog/filters.py +++ b/component_catalog/filters.py @@ -307,7 +307,6 @@ class VulnerabilityFilterSet(DataspacedFilterSet): fields=[ "max_score", "min_score", - "vulnerability_id", "affected_products_count", "affected_packages_count", "fixed_packages_length", diff --git a/component_catalog/templates/component_catalog/vulnerability_list.html b/component_catalog/templates/component_catalog/vulnerability_list.html index 5ebdddc4..ec99b8a0 100644 --- a/component_catalog/templates/component_catalog/vulnerability_list.html +++ b/component_catalog/templates/component_catalog/vulnerability_list.html @@ -13,4 +13,11 @@ +{% endblock %} + +{% block top-right-buttons %} + {{ block.super }} +
+ {{ filter.form.sort }} +
{% endblock %} \ No newline at end of file diff --git a/component_catalog/views.py b/component_catalog/views.py index ceec2de3..64e95e51 100644 --- a/component_catalog/views.py +++ b/component_catalog/views.py @@ -2491,7 +2491,8 @@ class VulnerabilityListView( table_headers = ( Header("vulnerability_id", _("Vulnerability")), Header("aliases", _("Aliases")), - Header("score_range", _("Score"), help_text="Severity score range", filter="max_score"), + # Keep `max_score` to enable column sorting + Header("max_score", _("Score"), help_text="Severity score range", filter="max_score"), Header("summary", _("Summary")), Header("affected_products_count", _("Affected products"), help_text="Affected products"), Header("affected_packages_count", _("Affected packages"), help_text="Affected packages"), diff --git a/purldb/templates/purldb/includes/filterset_modal.html b/dje/templates/modals/filterset_modal.html similarity index 72% rename from purldb/templates/purldb/includes/filterset_modal.html rename to dje/templates/modals/filterset_modal.html index 6aabba38..86f86e29 100644 --- a/purldb/templates/purldb/includes/filterset_modal.html +++ b/dje/templates/modals/filterset_modal.html @@ -1,14 +1,14 @@ {% load crispy_forms_tags %} -