From 17b8f6b3848be576a6972889ae624284177c7f78 Mon Sep 17 00:00:00 2001 From: tdruez Date: Tue, 16 Jul 2024 10:30:05 +0400 Subject: [PATCH] Add filters in the Dependencies tab #138 Signed-off-by: tdruez --- product_portfolio/filters.py | 12 +++++++++++ .../tabs/tab_dependencies.html | 6 +++++- product_portfolio/views.py | 21 ------------------- 3 files changed, 17 insertions(+), 22 deletions(-) diff --git a/product_portfolio/filters.py b/product_portfolio/filters.py index 53ca9341..cf592adf 100644 --- a/product_portfolio/filters.py +++ b/product_portfolio/filters.py @@ -333,6 +333,18 @@ class DependencyFilterSet(DataspacedFilterSet): "resolved_to_package__version", ], ) + is_runtime = BooleanChoiceFilter( + widget=DropDownWidget(anchor="#dependencies"), + ) + is_optional = BooleanChoiceFilter( + widget=DropDownWidget(anchor="#dependencies"), + ) + is_resolved = BooleanChoiceFilter( + widget=DropDownWidget(anchor="#dependencies"), + ) + is_direct = BooleanChoiceFilter( + widget=DropDownWidget(anchor="#dependencies"), + ) class Meta: model = ProductDependency diff --git a/product_portfolio/templates/product_portfolio/tabs/tab_dependencies.html b/product_portfolio/templates/product_portfolio/tabs/tab_dependencies.html index ab6452a0..6b2ebed7 100644 --- a/product_portfolio/templates/product_portfolio/tabs/tab_dependencies.html +++ b/product_portfolio/templates/product_portfolio/tabs/tab_dependencies.html @@ -35,15 +35,19 @@ {% trans 'Is runtime' %} + {{ filter_dependency.form.is_runtime }} {% trans 'Is optional' %} + {{ filter_dependency.form.is_optional }} {% trans 'Is resolved' %} + {{ filter_dependency.form.is_resolved }} {% trans 'Is direct' %} + {{ filter_dependency.form.is_direct }} @@ -65,7 +69,7 @@ {% endif %} - {{ dependency.scpe }} + {{ dependency.scope }} {{ dependency.is_runtime|as_icon }} diff --git a/product_portfolio/views.py b/product_portfolio/views.py index 4cb198a5..2f757c71 100644 --- a/product_portfolio/views.py +++ b/product_portfolio/views.py @@ -469,27 +469,6 @@ def tab_inventory(self): "fields": [(None, tab_context, None, template)], } - # def tab_dependencies(self): - # dependencies_count = self.object.dependencies.count() - # if not dependencies_count: - # return - # - # label = f'Dependencies {dependencies_count}' - # template = "product_portfolio/tabs/tab_dependencies.html" - # - # dependencies = self.object.dependencies.select_related( - # "for_package", - # "resolved_to_package", - # ) - # tab_context = { - # "dependencies": dependencies, - # } - # - # return { - # "label": format_html(label), - # "fields": [(None, tab_context, None, template)], - # } - def tab_dependencies(self): dependencies_count = self.object.dependencies.count() if not dependencies_count: