Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

report detail view fixes #106

Merged
merged 1 commit into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading