Skip to content

Commit

Permalink
Add a ProjectError list view #24
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Druez <[email protected]>
  • Loading branch information
tdruez committed Jan 18, 2021
1 parent b4e47fd commit 3007945
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 2 deletions.
37 changes: 37 additions & 0 deletions scanpipe/templates/scanpipe/error_list.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{% extends "scanpipe/base.html" %}

{% block content %}
<div class="container is-max-desktop mb-5">
{% include 'scanpipe/includes/navbar_header.html' %}
</div>

<div class="container is-fluid">
{% include 'scanpipe/includes/breadcrumb.html' with current="Errors" %}
<div class="table-container">
<table class="table is-bordered is-striped is-narrow is-hoverable is-fullwidth">
<thead>
<tr>
<th>Model</th>
<th>Message</th>
<th>Details</th>
<th>Traceback</th>
<th>Created date</th>
</tr>
</thead>
<tbody>
{% for error in object_list %}
<tr>
<td>{{ error.model }}</td>
<td>{{ error.message }}</td>
<td style="word-break: break-word;">{{ error.details }}</td>
<td>
<pre class="log p-0"><code>{{ error.traceback }}</code></pre>
</td>
<td>{{ error.created_date }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
{% endblock %}
10 changes: 9 additions & 1 deletion scanpipe/templates/scanpipe/includes/project_list_table.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,15 @@
{% endif %}
</td>
<td>
{{ project.error_count|intcomma }}
{% if project.error_count %}
<a href="{% url 'project_errors' project.uuid %}">
{{ project.error_count|intcomma }}
</a>
{% else %}
<span>
{{ project.error_count|intcomma }}
</span>
{% endif %}
</td>
<td>
{% for run in project.runs.all %}
Expand Down
12 changes: 11 additions & 1 deletion scanpipe/templates/scanpipe/includes/project_summary_level.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,17 @@
<div class="level-item has-text-centered">
<div>
<p class="heading">Errors</p>
<p class="{{ title_class }}">{{ project.error_count|intcomma }}</p>
<p class="{{ title_class }}">
{% if project.error_count %}
<a href="{% url 'project_errors' project.uuid %}">
{{ project.error_count|intcomma }}
</a>
{% else %}
<span>
{{ project.error_count|intcomma }}
</span>
{% endif %}
</p>
</div>
</div>
{% if include_pipelines %}
Expand Down
5 changes: 5 additions & 0 deletions scanpipe/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@
views.DiscoveredPackageListView.as_view(),
name="project_packages",
),
path(
"project/<uuid:uuid>/errors/",
views.ProjectErrorListView.as_view(),
name="project_errors",
),
path(
"project/<uuid:uuid>/tree/",
views.ProjectTreeView.as_view(),
Expand Down
7 changes: 7 additions & 0 deletions scanpipe/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
from scanpipe.models import CodebaseResource
from scanpipe.models import DiscoveredPackage
from scanpipe.models import Project
from scanpipe.models import ProjectError
from scanpipe.pipes import codebase
from scanpipe.pipes import outputs

Expand Down Expand Up @@ -284,3 +285,9 @@ class DiscoveredPackageListView(
template_name = "scanpipe/package_list.html"
paginate_by = 500
prefetch_related = ["codebase_resources"]


class ProjectErrorListView(ProjectRelatedViewMixin, generic.ListView):
model = ProjectError
template_name = "scanpipe/error_list.html"
paginate_by = 50

0 comments on commit 3007945

Please sign in to comment.