From 7154f196689ab20c6d1438e2740e8fecbefe7cc2 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Fri, 16 Oct 2020 14:36:40 +0200 Subject: [PATCH] admin: fix task list not being sorted --- passbook/admin/templates/administration/task/list.html | 6 +++--- passbook/admin/views/tasks.py | 4 +++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/passbook/admin/templates/administration/task/list.html b/passbook/admin/templates/administration/task/list.html index 31b31b460..b98197ebe 100644 --- a/passbook/admin/templates/administration/task/list.html +++ b/passbook/admin/templates/administration/task/list.html @@ -8,10 +8,10 @@

- + {% trans 'System Tasks' %}

-

{% trans "Background tasks." %}

+

{% trans "Long-running operations which passbook executes in the background." %}

@@ -28,7 +28,7 @@ - {% for key, task in object_list.items %} + {% for task in object_list %}
{{ task.task_name }}
diff --git a/passbook/admin/views/tasks.py b/passbook/admin/views/tasks.py index 796616993..7d0be779d 100644 --- a/passbook/admin/views/tasks.py +++ b/passbook/admin/views/tasks.py @@ -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