diff --git a/aleksis/core/templates/core/system_status.html b/aleksis/core/templates/core/system_status.html index a1f313efd843c6fea63cbc41f5ff7921d2ad5eaa..a62d024cf9ff5875ce61c8305b84834e47393726 100644 --- a/aleksis/core/templates/core/system_status.html +++ b/aleksis/core/templates/core/system_status.html @@ -62,4 +62,68 @@ </div> </div> </div> + + + {% if tasks %} + <div class="card"> + <div class="card-content"> + <span class="card-title"> {% blocktrans %}Celery task results{% endblocktrans %}</span> + + <table> + <thead> + <tr> + <th>{% trans "Task" %}</th> + <th>{% trans "ID" %}</th> + <th>{% trans "Date done" %}</th> + <th>{% trans "Status" %}</th> + </tr> + </thead> + <tbody> + {% for task in tasks %} + {% if task != None %} + <tr> + <td>{{ task.task_name }}</td> + <td>{{ task.task_id }}</td> + <td>{{ task.date_done }}</td> + <td> + {% if task.status == "PENDING" %} + <a class="tooltipped" data-position="top" + data-tooltip="{{ task.status }}"> + <i class="material-icons orange-text">hourglass_empty</i> + </a> + {% elif task.status == "STARTED" %} + <a class="tooltipped" data-position="top" + data-tooltip="{{ task.status }}"> + <i class="material-icons orange-text">directions_run</i> + </a> + {% elif task.status == "SUCCESS" %} + <a class="tooltipped" data-position="top" + data-tooltip="{{ task.status }}"> + <i class="material-icons green-text">done</i> + </a> + {% elif task.status == "FAILURE" %} + <a class="tooltipped" data-position="top" + data-tooltip="{{ task.status }}"> + <i class="material-icons red-text">error</i> + </a> + {% elif task.status == "RETRY" %} + <a class="tooltipped" data-position="top" + data-tooltip="{{ task.status }}"> + <i class="material-icons orange-text">hourglass_full</i> + </a> + {% elif task.status == "REVOKED" %} + <a class="tooltipped" data-position="top" + data-tooltip="{{ task.status }}"> + <i class="material-icons red-text">clear</i> + </a> + {% endif %} + </td> + </tr> + {% endif %} + {% endfor %} + </tbody> + </table> + </div> + </div> + {% endif %} {% endblock %} diff --git a/aleksis/core/views.py b/aleksis/core/views.py index 81dc709017dac791c2e239379cc9cf262bfe3e71..b5415c45d293218ac64d7003c905350ea02eb3ad 100644 --- a/aleksis/core/views.py +++ b/aleksis/core/views.py @@ -1,6 +1,7 @@ from typing import Optional from django.apps import apps +from django.conf import settings from django.contrib.auth.mixins import PermissionRequiredMixin from django.core.exceptions import PermissionDenied from django.core.paginator import Paginator @@ -295,6 +296,16 @@ def system_status(request: HttpRequest) -> HttpResponse: """View giving information about the system status.""" context = {} + if "django_celery_results" in settings.INSTALLED_APPS: + from django_celery_results.models import TaskResult # noqa + from celery.task.control import inspect # noqa + if inspect().registered_tasks(): + job_list = list(inspect().registered_tasks().values())[0] + results = [] + for job in job_list: + results.append(TaskResult.objects.filter(task_name=job).last()) + context["tasks"] = results + return render(request, "core/system_status.html", context)