Skip to content
Snippets Groups Projects
Commit 307532e9 authored by Jonathan Weth's avatar Jonathan Weth :keyboard:
Browse files

Merge branch '223-add-overview-page-for-celery-task-results' into 'master'

Resolve "Add overview page for celery task results"

Closes #223

See merge request AlekSIS!281
parents c04d7806 7d5e47d8
No related branches found
No related tags found
1 merge request!281Resolve "Add overview page for celery task results"
Pipeline #2487 failed
...@@ -62,4 +62,68 @@ ...@@ -62,4 +62,68 @@
</div> </div>
</div> </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 %} {% endblock %}
from typing import Optional from typing import Optional
from django.apps import apps from django.apps import apps
from django.conf import settings
from django.contrib.auth.mixins import PermissionRequiredMixin from django.contrib.auth.mixins import PermissionRequiredMixin
from django.core.exceptions import PermissionDenied from django.core.exceptions import PermissionDenied
from django.core.paginator import Paginator from django.core.paginator import Paginator
...@@ -295,6 +296,16 @@ def system_status(request: HttpRequest) -> HttpResponse: ...@@ -295,6 +296,16 @@ def system_status(request: HttpRequest) -> HttpResponse:
"""View giving information about the system status.""" """View giving information about the system status."""
context = {} 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) return render(request, "core/system_status.html", context)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment