Skip to content

Commit 0fc6b32

Browse files
committed
Refine the consistency of Product import actions #241
Signed-off-by: tdruez <[email protected]>
1 parent 12b5806 commit 0fc6b32

File tree

8 files changed

+40
-19
lines changed

8 files changed

+40
-19
lines changed
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{% if form.errors %}
2-
<div class="alert alert-danger alert-dismissible" role="alert">
3-
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
2+
<div class="alert alert-danger" role="alert">
43
<p class="m-0">Please correct the error{{ form.errors|pluralize }} below.</p>
54
</div>
65
{% endif %}

product_portfolio/forms.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,6 @@ def save(self, product):
600600

601601
class BaseProductImportFormView(forms.Form):
602602
project_type = None
603-
input_label = ""
604603

605604
input_file = SmartFileField(
606605
label=_("file or zip archive"),
@@ -629,10 +628,6 @@ class BaseProductImportFormView(forms.Form):
629628
),
630629
)
631630

632-
def __init__(self, *args, **kwargs):
633-
super().__init__(*args, **kwargs)
634-
self.fields["input_file"].label = _(f"{self.input_label} file or zip archive")
635-
636631
@property
637632
def helper(self):
638633
helper = FormHelper()
@@ -664,15 +659,24 @@ def submit(self, product, user):
664659

665660
class LoadSBOMsForm(BaseProductImportFormView):
666661
project_type = ScanCodeProject.ProjectType.LOAD_SBOMS
667-
input_label = "SBOM"
668662
pipeline_name = "load_sbom"
669663

664+
input_file = SmartFileField(
665+
label=_("SBOM file or zip archive"),
666+
extensions=["json", "ABOUT", "zip"],
667+
required=True,
668+
)
669+
670670

671671
class ImportManifestsForm(BaseProductImportFormView):
672672
project_type = ScanCodeProject.ProjectType.IMPORT_FROM_MANIFEST
673-
input_label = "Manifest"
674673
pipeline_name = "resolve_dependencies"
675674

675+
input_file = SmartFileField(
676+
label=_("Manifest file or zip archive"),
677+
required=True,
678+
)
679+
676680

677681
class StrongTextWidget(forms.Widget):
678682
def render(self, name, value, attrs=None, renderer=None):
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Generated by Django 5.1.6 on 2025-02-20 21:04
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('product_portfolio', '0011_alter_product_owner'),
10+
]
11+
12+
operations = [
13+
migrations.AlterField(
14+
model_name='scancodeproject',
15+
name='type',
16+
field=models.CharField(choices=[('IMPORT_FROM_MANIFEST', 'Import Package manifests'), ('LOAD_SBOMS', 'Import SBOM'), ('PULL_FROM_SCANCODEIO', 'Import ScanCode.io project'), ('IMPROVE_FROM_PURLDB', 'Improve from PurlDB')], db_index=True, help_text='The type of import, for the ProjectType choices.', max_length=50),
17+
),
18+
]

product_portfolio/models.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1460,9 +1460,9 @@ class ScanCodeProject(HistoryFieldsMixin, DataspacedModel):
14601460
"""Wrap a ScanCode.io Project."""
14611461

14621462
class ProjectType(models.TextChoices):
1463-
IMPORT_FROM_MANIFEST = "IMPORT_FROM_MANIFEST", _("Import from Manifest")
1464-
LOAD_SBOMS = "LOAD_SBOMS", _("Load SBOMs")
1465-
PULL_FROM_SCANCODEIO = "PULL_FROM_SCANCODEIO", _("Pull from ScanCode.io")
1463+
IMPORT_FROM_MANIFEST = "IMPORT_FROM_MANIFEST", _("Import Package manifests")
1464+
LOAD_SBOMS = "LOAD_SBOMS", _("Import SBOM")
1465+
PULL_FROM_SCANCODEIO = "PULL_FROM_SCANCODEIO", _("Import ScanCode.io project")
14661466
IMPROVE_FROM_PURLDB = "IMPROVE_FROM_PURLDB", _("Improve from PurlDB")
14671467

14681468
class Status(models.TextChoices):

product_portfolio/templates/product_portfolio/import_manifests_form.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ <h1 class="header-title">
6060

6161
<div class="row">
6262
<div class="col-8">
63-
{{ form.errors }}
63+
{% include 'includes/form_errors_alert.html' %}
6464
{% crispy form %}
6565
</div>
6666
</div>

product_portfolio/templates/product_portfolio/load_sboms_form.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ <h1 class="header-title">
6262

6363
<div class="row">
6464
<div class="col-8">
65-
{{ form.errors }}
65+
{% include 'includes/form_errors_alert.html' %}
6666
{% crispy form %}
6767
</div>
6868
</div>

product_portfolio/templates/product_portfolio/product_details.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,12 @@
3838
<div class="dropdown-header">Import</div>
3939
{% if has_change_permission %}
4040
{% if request.user.dataspace.enable_package_scanning %}
41-
<a class="dropdown-item" href="{{ object.get_load_sboms_url }}"><i class="fas fa-file-upload"></i> {% trans 'Import SBOM' %}</a>
42-
<a class="dropdown-item" href="{{ object.get_import_manifests_url }}"><i class="fas fa-file-upload"></i> {% trans 'Import Package manifests' %}</a>
41+
<a class="dropdown-item" href="{{ object.get_load_sboms_url }}"><i class="fas fa-file-upload"></i> Import <strong>SBOM</strong></a>
42+
<a class="dropdown-item" href="{{ object.get_import_manifests_url }}"><i class="fas fa-file-upload"></i> Import Package <strong>manifests</strong></a>
4343
{% endif %}
44-
<a class="dropdown-item" href="{{ object.get_import_from_scan_url }}"><i class="fas fa-file-upload"></i> {% trans 'Import ScanCode scan results' %}</a>
44+
<a class="dropdown-item" href="{{ object.get_import_from_scan_url }}"><i class="fas fa-file-upload"></i> Import ScanCode <strong>scan results</strong></a>
4545
{% if pull_project_data_form %}
46-
<a class="dropdown-item" href="#" data-bs-toggle="modal" data-bs-target="#pull-project-data-modal"><i class="fas fa-file-upload"></i> {% trans 'Import ScanCode.io project' %}</a>
46+
<a class="dropdown-item" href="#" data-bs-toggle="modal" data-bs-target="#pull-project-data-modal"><i class="fas fa-file-upload"></i> Import ScanCode.io <strong>project</strong></a>
4747
{% endif %}
4848
{% endif %}
4949
{% if has_scan_all_packages %}

product_portfolio/templates/product_portfolio/scancodeio_project_status.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ <h5>{{ values|length }} {{ object_type }} updated/existing:</h5>
4343
<ul class="list-unstyled mb-1">
4444
<li><strong>Pipeline name:</strong> {{ run.pipeline_name }}</li>
4545
<li>
46-
<strong>Status:</strong>
46+
<strong>Pipeline status:</strong>
4747
<span class="badge
4848
{% if run.status == 'success' %}
4949
text-bg-success

0 commit comments

Comments
 (0)