Skip to content

Commit

Permalink
report detail view fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
amyasnikov committed Sep 16, 2024
1 parent 98dec35 commit a2cd16b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 12 deletions.
24 changes: 19 additions & 5 deletions validity/templates/validity/compliancereport.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ <h5 class="card-header">Compliance Report</h5>
{% with job=object.jobs.first %}
<tr>
<th scope="row">Job</th>
<td>{% if job %}{{ job | linkify }} | {{ job | colored_choice:"status" }}{% else %}—{% endif %}</td>
<td>
{% if job %}<a href="{{ job.get_absolute_url }}">{{ job.pk }}</a>
| {{ job | colored_choice:"status" }}{% else %}—{% endif %}
</td>
</tr>
{% if job.error %}
<tr>
Expand All @@ -46,10 +49,21 @@ <h5 class="card-header">Compliance Report</h5>
<th scope="row">Unique Tests involved</th>
<td>{{ object.test_count }}</td>
</tr>
{% report_stats_row object "Overall Results" "total" %}
{% report_stats_row object "LOW Severity Results" "low" %}
{% report_stats_row object "MIDDLE Severity Results" "middle" %}
{% report_stats_row object "HIGH Severity Results" "high" %}
<tr>
<th>Overall Results</th>
<td>{% report_stats object "total" %}</td>
</tr>
</table>
<div class="card-header"></div>
<table class="table table-hover">
<tr>
<th>LOW Severity</th><th>MIDDLE Severity</th><th>HIGH Severity</th>
</tr>
<tr>
<td>{% report_stats object "low" %}</td>
<td>{% report_stats object "middle" %}</td>
<td>{% report_stats object "high" %}</td>
</tr>
</table>
</div>
</div>
Expand Down
12 changes: 5 additions & 7 deletions validity/templatetags/validity.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,16 +73,14 @@ def urljoin(*parts: str) -> str:
return "/".join(url_parts)


@register.inclusion_tag("validity/inc/report_stats_row.html")
def report_stats_row(obj, row_name, severity):
for i, row_part in enumerate((row_parts := row_name.split())):
if row_part.lower() in {"low", "middle", "high"}:
row_parts[i] = f"<b>{row_part.upper()}</b>"
row_name = mark_safe(" ".join(row_parts))
@register.simple_tag
def report_stats(obj, severity):
count = getattr(obj, f"{severity}_count")
if count == 0:
return "—"
passed = getattr(obj, f"{severity}_passed")
percentage = getattr(obj, f"{severity}_percentage")
return {"row_name": row_name, "passed": passed, "count": count, "percentage": percentage}
return mark_safe(f"{passed}/{count} ") + colorful_percentage(percentage)


@register.simple_tag
Expand Down

0 comments on commit a2cd16b

Please sign in to comment.