diff --git a/django_rq/templates/django_rq/failed_jobs.html b/django_rq/templates/django_rq/failed_jobs.html new file mode 100644 index 00000000..f5fec00f --- /dev/null +++ b/django_rq/templates/django_rq/failed_jobs.html @@ -0,0 +1,170 @@ +{% extends "admin/base_site.html" %} + +{% load static jquery_path django_rq %} + +{% block title %}{{ job_status }} Jobs in {{ queue.name }} {{ block.super }}{% endblock %} + +{% block extrastyle %} + {{ block.super }} + +{% endblock %} + +{% block extrahead %} + {{ block.super }} + + + + +{% endblock %} + + +{% block breadcrumbs %} + +{% endblock %} + +{% block content_title %}

{{ job_status }} jobs in {{ queue.name }}

{% endblock %} + +{% block content %} + +
+ +
+
+
+ {% csrf_token %} +
+ + +
+
+ + + + + + + + + + + {% block extra_columns %} + {% endblock extra_columns %} + + + + {% for job in jobs %} + + + + + {% if job_status == 'Scheduled' %} + + {% endif %} + + + + + {% block extra_columns_values %} + {% endblock extra_columns_values %} + + {% endfor %} + +
+
+ +
+
+
+
ID
+
+
+
Created
+
+
+
Enqueued
+
+
+
+ {% if sort_direction == 'ascending' %} + + {% else %} + + {% endif %} +
+
+ {% if sort_direction == 'ascending' %} + + {% else %} + + {% endif %} + Ended + +
+
+
+
Status
+
+
+
Callable
+
+
+ + + + {{ job.id }} + + + {% if job.created_at %} + {{ job.created_at|to_localtime|date:"Y-m-d, H:i:s" }} + {% endif %} + + {% if job.scheduled_at %} + {{ job.scheduled_at|to_localtime|date:"Y-m-d, H:i:s" }} + {% endif %} + + {% if job.enqueued_at %} + {{ job.enqueued_at|to_localtime|date:"Y-m-d, H:i:s" }} + {% endif %} + + {% if job.ended_at %} + {{ job.ended_at|to_localtime|date:"Y-m-d, H:i:s" }} + {% endif %} + {{ job.get_status.value }}{{ job|show_func_name }}
+
+

+ {% for p in page_range %} + {% if p == page %} + {{ p }} + {% elif forloop.last %} + {{ p }} + {% else %} + {{ p }} + {% endif %} + {% endfor %} + {{ num_jobs }} jobs +

+
+
+
+
+ +{% endblock %} diff --git a/django_rq/templates/django_rq/job_detail.html b/django_rq/templates/django_rq/job_detail.html index 68ef0594..cece1e90 100644 --- a/django_rq/templates/django_rq/job_detail.html +++ b/django_rq/templates/django_rq/job_detail.html @@ -110,7 +110,7 @@
-
{{ job.get_status }}
+
{{ job.get_status.value }}
diff --git a/django_rq/templates/django_rq/jobs.html b/django_rq/templates/django_rq/jobs.html index 054b39dd..bd53a29a 100644 --- a/django_rq/templates/django_rq/jobs.html +++ b/django_rq/templates/django_rq/jobs.html @@ -141,7 +141,7 @@ {{ job.ended_at|to_localtime|date:"Y-m-d, H:i:s" }} {% endif %} - {{ job.get_status }} + {{ job.get_status.value }} {{ job|show_func_name }} {% block extra_columns_values %} {% endblock extra_columns_values %} diff --git a/django_rq/views.py b/django_rq/views.py index 035a601f..550949e3 100644 --- a/django_rq/views.py +++ b/django_rq/views.py @@ -128,13 +128,19 @@ def failed_jobs(request, queue_index): items_per_page = 100 num_jobs = len(registry) page = int(request.GET.get('page', 1)) + + if request.GET.get('desc', '1') == '1': + sort_direction = 'descending' + else: + sort_direction = 'ascending' + jobs = [] if num_jobs > 0: last_page = int(ceil(num_jobs / items_per_page)) page_range = list(range(1, last_page + 1)) offset = items_per_page * (page - 1) - job_ids = registry.get_job_ids(offset, offset + items_per_page - 1, desc=True) + job_ids = registry.get_job_ids(offset, offset + items_per_page - 1, desc=sort_direction == 'descending') jobs = get_jobs(queue, job_ids, registry) else: @@ -149,8 +155,9 @@ def failed_jobs(request, queue_index): 'page': page, 'page_range': page_range, 'job_status': 'Failed', + 'sort_direction': sort_direction, } - return render(request, 'django_rq/jobs.html', context_data) + return render(request, 'django_rq/failed_jobs.html', context_data) @never_cache