Skip to content

Commit

Permalink
Proper display of the improve_packages_from_purldb link #45
Browse files Browse the repository at this point in the history
Signed-off-by: tdruez <tdruez@nexb.com>
  • Loading branch information
tdruez committed Sep 2, 2024
1 parent c115146 commit ee586e8
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ Release notes
- Add a Vulnerabilities tab in the Product details view.
https://github.com/aboutcode-org/dejacode/issues/95

- Add a "Improve Packages from PurlDB" action in the Product details view.
https://github.com/aboutcode-org/dejacode/issues/45

### Version 5.1.0

- Upgrade Python version to 3.12 and Django to 5.0.x
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
<div class="dropdown-header">ScanCode.io</div>
<a class="dropdown-item{% if not tabsets.Inventory %} disabled{% endif %}" href="#" data-bs-toggle="modal" data-bs-target="#scan-all-packages-modal"><i class="fas fa-barcode"></i> {% trans 'Scan all Packages' %}</a>
{% endif %}
{% if has_change_permission %}{# TODO: Only if PurlDB is configured! #}
{% if request.user.dataspace.enable_purldb_access %}
<div class="dropdown-header">PurlDB</div>
<a class="dropdown-item" href="{{ object.get_improve_packages_from_purldb_url }}"><i class="fas fa-database"></i> {% trans 'Improve Packages from PurlDB' %}</a>
{% endif %}
Expand Down
26 changes: 24 additions & 2 deletions product_portfolio/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@ def test_product_portfolio_detail_view_inventory_tab_display_scan_features(
self.assertContains(response, expected1)
self.assertContains(response, expected2)

def test_product_detail_view_inventory_tab_display_vulnerabilities(self):
def test_product_portfolio_detail_view_inventory_tab_display_vulnerabilities(self):
ProductPackage.objects.create(
product=self.product1, package=self.package1, dataspace=self.dataspace
)
Expand Down Expand Up @@ -637,7 +637,7 @@ def test_product_portfolio_detail_view_feature_field_grouping_in_inventory_tab(s
response, '<td colspan="100" class="sub-header"><strong>f2</strong></td>'
)

def test_product_portfolio_details_view_configuration_status(self):
def test_product_portfolio_detail_view_configuration_status(self):
self.client.login(username="nexb_user", password="secret")

configuration_status = ProductStatus.objects.create(
Expand Down Expand Up @@ -934,6 +934,28 @@ def test_product_portfolio_detail_edit_productcomponent_permissions(self):
response = self.client.get(url)
self.assertContains(response, delete_button)

def test_product_portfolio_detail_view_display_purldb_features(self):
self.client.login(username=self.super_user.username, password="secret")
self.assertFalse(self.super_user.dataspace.enable_purldb_access)
url = self.product1.get_absolute_url()

expected1 = '<div class="dropdown-header">PurlDB</div>'
expected2 = "Improve Packages from PurlDB"
expected3 = self.product1.get_url("improve_packages_from_purldb")

response = self.client.get(url)
self.assertNotContains(response, expected1)
self.assertNotContains(response, expected2)
self.assertNotContains(response, expected3)

self.dataspace.enable_purldb_access = True
self.dataspace.save()
url = self.product1.get_absolute_url()
response = self.client.get(url)
self.assertContains(response, expected1)
self.assertContains(response, expected2)
self.assertContains(response, expected3)

def test_product_portfolio_list_view_secured_queryset(self):
self.client.login(username=self.basic_user.username, password="secret")
url = resolve_url("product_portfolio:product_list")
Expand Down

0 comments on commit ee586e8

Please sign in to comment.