admin: fix task list not being sorted

This commit is contained in:
Jens Langhammer 2020-10-16 14:36:40 +02:00
parent 8fedd9ec07
commit 7154f19668
2 changed files with 6 additions and 4 deletions

View File

@ -8,10 +8,10 @@
<section class="pf-c-page__main-section pf-m-light">
<div class="pf-c-content">
<h1>
<i class="fas fa-key"></i>
<i class="pf-icon pf-icon-automation"></i>
{% trans 'System Tasks' %}
</h1>
<p>{% trans "Background tasks." %}</p>
<p>{% trans "Long-running operations which passbook executes in the background." %}</p>
</div>
</section>
<section class="pf-c-page__main-section pf-m-no-padding-mobile">
@ -28,7 +28,7 @@
</tr>
</thead>
<tbody role="rowgroup">
{% for key, task in object_list.items %}
{% for task in object_list %}
<tr role="row">
<th role="columnheader">
<pre>{{ task.task_name }}</pre>

View File

@ -14,7 +14,9 @@ class TaskListView(AdminRequiredMixin, TemplateView):
def get_context_data(self, **kwargs: Any) -> Dict[str, Any]:
kwargs = super().get_context_data(**kwargs)
kwargs["object_list"] = TaskInfo.all()
kwargs["object_list"] = sorted(
TaskInfo.all().values(), key=lambda x: x.task_name
)
kwargs["task_successful"] = TaskResultStatus.SUCCESSFUL
kwargs["task_warning"] = TaskResultStatus.WARNING
kwargs["task_error"] = TaskResultStatus.ERROR