Skip to content

Commit 7da220c

Browse files
committed
Refine the QuerySet and rendering og the Package set tab #276
Signed-off-by: tdruez <tdruez@nexb.com>
1 parent 1a8b4d1 commit 7da220c

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

component_catalog/templates/component_catalog/tabs/tab_package_set.html

+3-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
<th>{% trans 'Package URL' %}</th>
77
<th>{% trans 'Download URL' %}</th>
88
<th>{% trans 'Filename' %}</th>
9+
<th>{% trans 'Concluded license' %}</th>
910
</tr>
1011
</thead>
1112
<tbody>
@@ -21,8 +22,9 @@
2122
<a href="{{ package.get_absolute_url }}" target="_blank">{{ package.package_url }}</a>
2223
{% endif %}
2324
</td>
24-
<td>{{ package.download_url|default_if_none:"" }}</td>
2525
<td>{{ package.filename|default_if_none:"" }}</td>
26+
<td>{{ package.download_url|default_if_none:"" }}</td>
27+
<td>{{ package.license_expression|default_if_none:"" }}</td>
2628
</tr>
2729
{% endfor %}
2830
</tbody>

component_catalog/views.py

+19-1
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
from component_catalog.license_expression_dje import get_unique_license_keys
6868
from component_catalog.models import Component
6969
from component_catalog.models import Package
70+
from component_catalog.models import PACKAGE_URL_FIELDS
7071
from component_catalog.models import PackageAlreadyExistsWarning
7172
from component_catalog.models import Subcomponent
7273
from dejacode_toolkit.download import DataCollectionException
@@ -1300,7 +1301,24 @@ def tab_others(self):
13001301

13011302
def tab_package_set(self):
13021303
plain_url = self.object.plain_package_url
1303-
related_packages = self.get_queryset().for_package_url(plain_url)
1304+
related_packages = (
1305+
self.model.objects.scope(self.object.dataspace)
1306+
.for_package_url(plain_url)
1307+
.only(
1308+
"uuid",
1309+
*PACKAGE_URL_FIELDS,
1310+
"filename",
1311+
"download_url",
1312+
"license_expression",
1313+
"dataspace__name",
1314+
)
1315+
.order_by(
1316+
*PACKAGE_URL_FIELDS,
1317+
"filename",
1318+
"download_url",
1319+
)
1320+
.distinct()
1321+
)
13041322

13051323
template = "component_catalog/tabs/tab_package_set.html"
13061324
if len(related_packages) > 1:

0 commit comments

Comments
 (0)