mirror of
https://github.com/django-q2/django-q2.git
synced 2026-09-29 17:28:12 +08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f8501bfb4c | ||
|
|
23c06a38eb |
@@ -2,6 +2,12 @@
|
|||||||
|
|
||||||
## [Unreleased](https://github.com/GDay/django-q2/tree/HEAD)
|
## [Unreleased](https://github.com/GDay/django-q2/tree/HEAD)
|
||||||
|
|
||||||
|
## [v1.5.4](https://github.com/GDay/django-q2/tree/v1.5.4) (2023-06-29)
|
||||||
|
|
||||||
|
**Merged pull requests:**
|
||||||
|
|
||||||
|
- Rerun successful tasks https://github.com/django-q2/django-q2/pull/99
|
||||||
|
|
||||||
## [v1.5.3](https://github.com/GDay/django-q2/tree/v1.5.3) (2023-05-14)
|
## [v1.5.3](https://github.com/GDay/django-q2/tree/v1.5.3) (2023-05-14)
|
||||||
|
|
||||||
**Merged pull requests:**
|
**Merged pull requests:**
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import django
|
import django
|
||||||
|
|
||||||
VERSION = (1, 5, 3)
|
VERSION = (1, 5, 4)
|
||||||
|
|
||||||
if django.VERSION < (3, 2):
|
if django.VERSION < (3, 2):
|
||||||
default_app_config = "django_q.apps.DjangoQConfig"
|
default_app_config = "django_q.apps.DjangoQConfig"
|
||||||
|
|||||||
+20
-12
@@ -10,10 +10,29 @@ from django_q.models import Failure, OrmQ, Schedule, Success, Task
|
|||||||
from django_q.tasks import async_task
|
from django_q.tasks import async_task
|
||||||
|
|
||||||
|
|
||||||
|
def resubmit_task(model_admin, request, queryset):
|
||||||
|
"""Submit selected tasks back to the queue."""
|
||||||
|
for task in queryset:
|
||||||
|
async_task(
|
||||||
|
task.func,
|
||||||
|
*task.args or (),
|
||||||
|
hook=task.hook,
|
||||||
|
group=task.group,
|
||||||
|
cluster=task.cluster,
|
||||||
|
**task.kwargs or {},
|
||||||
|
)
|
||||||
|
if isinstance(model_admin, FailAdmin):
|
||||||
|
task.delete()
|
||||||
|
|
||||||
|
|
||||||
|
resubmit_task.short_description = _("Resubmit selected tasks to queue")
|
||||||
|
|
||||||
|
|
||||||
class TaskAdmin(admin.ModelAdmin):
|
class TaskAdmin(admin.ModelAdmin):
|
||||||
"""model admin for success tasks."""
|
"""model admin for success tasks."""
|
||||||
|
|
||||||
list_display = ("name", "group", "func", "cluster", "started", "stopped", "time_taken")
|
list_display = ("name", "group", "func", "cluster", "started", "stopped", "time_taken")
|
||||||
|
actions = [resubmit_task]
|
||||||
|
|
||||||
def has_add_permission(self, request):
|
def has_add_permission(self, request):
|
||||||
"""Don't allow adds."""
|
"""Don't allow adds."""
|
||||||
@@ -33,17 +52,6 @@ class TaskAdmin(admin.ModelAdmin):
|
|||||||
return list(self.readonly_fields) + [field.name for field in obj._meta.fields]
|
return list(self.readonly_fields) + [field.name for field in obj._meta.fields]
|
||||||
|
|
||||||
|
|
||||||
def retry_failed(FailAdmin, request, queryset):
|
|
||||||
"""Submit selected tasks back to the queue."""
|
|
||||||
for task in queryset:
|
|
||||||
async_task(task.func, *task.args or (), hook=task.hook,
|
|
||||||
group=task.group, cluster=task.cluster, **task.kwargs or {})
|
|
||||||
task.delete()
|
|
||||||
|
|
||||||
|
|
||||||
retry_failed.short_description = _("Resubmit selected tasks to queue")
|
|
||||||
|
|
||||||
|
|
||||||
class FailAdmin(admin.ModelAdmin):
|
class FailAdmin(admin.ModelAdmin):
|
||||||
"""model admin for failed tasks."""
|
"""model admin for failed tasks."""
|
||||||
|
|
||||||
@@ -53,7 +61,7 @@ class FailAdmin(admin.ModelAdmin):
|
|||||||
"""Don't allow adds."""
|
"""Don't allow adds."""
|
||||||
return False
|
return False
|
||||||
|
|
||||||
actions = [retry_failed]
|
actions = [resubmit_task]
|
||||||
search_fields = ("name", "func", "group")
|
search_fields = ("name", "func", "group")
|
||||||
list_filter = ("group", "cluster")
|
list_filter = ("group", "cluster")
|
||||||
readonly_fields = []
|
readonly_fields = []
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ def test_admin_views(admin_client, monkeypatch):
|
|||||||
|
|
||||||
# resubmit the failure
|
# resubmit the failure
|
||||||
url = reverse("admin:django_q_failure_changelist")
|
url = reverse("admin:django_q_failure_changelist")
|
||||||
data = {"action": "retry_failed", "_selected_action": [f.pk]}
|
data = {"action": "resubmit_task", "_selected_action": [f.pk]}
|
||||||
response = admin_client.post(url, data)
|
response = admin_client.post(url, data)
|
||||||
assert response.status_code == 302
|
assert response.status_code == 302
|
||||||
assert Failure.objects.filter(name=f.id).exists() is False
|
assert Failure.objects.filter(name=f.id).exists() is False
|
||||||
@@ -84,3 +84,10 @@ def test_admin_views(admin_client, monkeypatch):
|
|||||||
data = {"post": "yes"}
|
data = {"post": "yes"}
|
||||||
response = admin_client.post(url, data)
|
response = admin_client.post(url, data)
|
||||||
assert response.status_code == 302
|
assert response.status_code == 302
|
||||||
|
# Resubmit a successful task.
|
||||||
|
url = reverse("admin:django_q_success_changelist")
|
||||||
|
data = {"action": "resubmit_task", "_selected_action": [t.pk]}
|
||||||
|
initial_queue_count = OrmQ.objects.count()
|
||||||
|
response = admin_client.post(url, data)
|
||||||
|
assert response.status_code == 302
|
||||||
|
assert OrmQ.objects.count() > initial_queue_count
|
||||||
|
|||||||
+1
-1
@@ -75,7 +75,7 @@ author = "Ilan Steemers, Stan Triepels"
|
|||||||
# The short X.Y version.
|
# The short X.Y version.
|
||||||
version = "1.5"
|
version = "1.5"
|
||||||
# The full version, including alpha/beta/rc tags.
|
# The full version, including alpha/beta/rc tags.
|
||||||
release = "1.5.3"
|
release = "1.5.4"
|
||||||
|
|
||||||
# The language for content autogenerated by Sphinx. Refer to documentation
|
# The language for content autogenerated by Sphinx. Refer to documentation
|
||||||
# for a list of supported languages.
|
# for a list of supported languages.
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
[tool.poetry]
|
[tool.poetry]
|
||||||
name = "django-q2"
|
name = "django-q2"
|
||||||
version = "1.5.3"
|
version = "1.5.4"
|
||||||
packages = [
|
packages = [
|
||||||
{ include = "django_q" },
|
{ include = "django_q" },
|
||||||
]
|
]
|
||||||
|
|||||||
Reference in New Issue
Block a user