Skip to content

Commit

Permalink
Pass more summary data to project view
Browse files Browse the repository at this point in the history
    * Add fontawesome v 5.13.0

Reference: #411

Signed-off-by: Jono Yang <jyang@nexb.com>
  • Loading branch information
JonoYang committed Jun 17, 2022
1 parent 3f71faa commit 9f2679d
Show file tree
Hide file tree
Showing 19 changed files with 9,386 additions and 8 deletions.
5 changes: 5 additions & 0 deletions scancodeio/static/fontawesome/css/all-5.13.0.min.css

Large diffs are not rendered by default.

Binary file not shown.
3,570 changes: 3,570 additions & 0 deletions scancodeio/static/fontawesome/webfonts/fa-brands-400.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
803 changes: 803 additions & 0 deletions scancodeio/static/fontawesome/webfonts/fa-regular-400.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
4,938 changes: 4,938 additions & 0 deletions scancodeio/static/fontawesome/webfonts/fa-solid-900.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
1 change: 1 addition & 0 deletions scanpipe/templates/scanpipe/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<link rel="icon" href="{% static 'favicon.ico' %}">
<link rel="stylesheet" href="{% static 'bulma-0.9.4.min.css' %}" crossorigin="anonymous">
<link rel="stylesheet" href="{% static 'highlight-10.6.0.css' %}" crossorigin="anonymous">
<link rel="stylesheet" href="{% static 'fontawesome/css/all-5.13.0.min.css' %}" crossorigin="anonymous">
<style>
.width-100, .select, .select select {width: 100%;}
.has-border-radius {border-radius: 6px;}
Expand Down
28 changes: 25 additions & 3 deletions scanpipe/templates/scanpipe/project_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
{% endif %}
</section>

{% if summary_data %}
{% if license_clarity %}
<article id="license-clarity-fields" class="panel is-info mx-5">
<p class="panel-heading py-2 is-size-6">
License Clarity
Expand All @@ -102,7 +102,7 @@
<table class="table table-bordered table-md">
<thead>
<tr>
{% for entry in summary_data %}
{% for entry in license_clarity %}
<th>
{% if entry.help_text %}
<span class="help_text" data-toggle="tooltip" data-placement="top" title="{{ entry.help_text }}">
Expand All @@ -117,7 +117,7 @@
</thead>
<tbody>
<tr>
{% for entry in summary_data %}
{% for entry in license_clarity %}
<td{% if entry.td_class %} class="{{ entry.td_class }}"{% endif %}>{{ entry.value }}</td>
{% endfor %}
</tr>
Expand All @@ -130,6 +130,28 @@
</article>
{% endif %}

{% if summary_data %}
<article id="summary-info" class="panel is-info mx-5">
<p class="panel-heading py-2 is-size-6">
Summary
</p>
<div class="panel-block p-0">
<figure class="highlight border-bottom-radius">
{% for s in summary_data %}
<dt class="col-sm-2 text-right pt-2 pr-0">{{ s.label }}</dt>
{% for value in s.values %}
{% if value.value %}
<dd class="col-sm-10"><pre class="pre-bg-light mb-1">{{ value.value }}</pre></dd>
{% else %}
<dd class="col-sm-10"><pre class="pre-bg-light mb-1">{{ value }}</pre></dd>
{% endif %}
{% endfor %}
{% endfor %}
</figure>
</div>
</article>
{% endif %}

{% if project.package_count %}
<hr class="mx-5">
<h3 class="title is-4 has-text-centered">
Expand Down
49 changes: 44 additions & 5 deletions scanpipe/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ def get_context_data(self, **kwargs):
message = "WARNING: This project is archived and read-only."
messages.warning(self.request, message)

license_clarity = []
summary_data = []
summary_file = project.get_latest_output(filename="summary")
if summary_file:
Expand Down Expand Up @@ -295,25 +296,62 @@ def as_icon(field_value):
}.get(field_value)

if icon:
return format_html('<i class="{} fa-md"></i>', icon)
return format_html('<i class="{}"></i>', icon)

for label, field, help_text in license_clarity_fields:
value = license_clarity_score.get(field)
if value is not None:
if field == 'discovered':
value = f'{int(value * 100)}%'
elif value in [True, False]:
if value in [True, False]:
value = as_icon(value)
else:
value = escape(value)

summary_data.append({
license_clarity.append({
'label': label,
'value': value,
'help_text': help_text,
'td_class': 'text-center',
})

summary_fields = [
('Primary License Expression', 'primary_license_expression'),
('Declared License Expressions', 'declared_license_expressions'),
('License Expressions', 'license_expressions'),
('Copyright Holders', 'holders')
]
for field_title, field_name in summary_fields:
value = summary.get(field_name)
if not value:
continue
if field_name == 'primary_license_expression':
summary_data.append(
{
"label": field_title,
"values": [value],
}
)
elif field_name == 'declared_license_expressions':
summary_data.append(
{
"label": field_title,
"values": value,
}
)
else:
values = [
{
"value": entry.get("value"),
"count": entry.get("count"),
}
for entry in value
]
summary_data.append(
{
"label": field_title,
"values": values,
}
)

context.update(
{
"inputs_with_source": inputs,
Expand All @@ -330,6 +368,7 @@ def as_icon(field_value):
"add_pipeline_form": AddPipelineForm(),
"add_inputs_form": AddInputsForm(),
"archive_form": ArchiveProjectForm(),
"license_clarity": license_clarity,
"summary_data": summary_data,
}
)
Expand Down

0 comments on commit 9f2679d

Please sign in to comment.