Skip to content

Commit

Permalink
Add filters in the Dependencies tab #138
Browse files Browse the repository at this point in the history
Signed-off-by: tdruez <[email protected]>
  • Loading branch information
tdruez committed Jul 16, 2024
1 parent db04c6d commit 17b8f6b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 22 deletions.
12 changes: 12 additions & 0 deletions product_portfolio/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,19 @@
</th>
<th>
{% trans 'Is runtime' %}
{{ filter_dependency.form.is_runtime }}
</th>
<th>
{% trans 'Is optional' %}
{{ filter_dependency.form.is_optional }}
</th>
<th>
{% trans 'Is resolved' %}
{{ filter_dependency.form.is_resolved }}
</th>
<th>
{% trans 'Is direct' %}
{{ filter_dependency.form.is_direct }}
</th>
</tr>
</thead>
Expand All @@ -65,7 +69,7 @@
{% endif %}
</td>
<td>
{{ dependency.scpe }}
{{ dependency.scope }}
</td>
<td>
{{ dependency.is_runtime|as_icon }}
Expand Down
21 changes: 0 additions & 21 deletions product_portfolio/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 <span class="badge text-bg-primary">{dependencies_count}</span>'
# 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:
Expand Down

0 comments on commit 17b8f6b

Please sign in to comment.