From 579496b066278d988f4a8b025f81aac79c89af54 Mon Sep 17 00:00:00 2001 From: PiotrIw Date: Thu, 20 Jun 2024 10:51:46 +0000 Subject: [PATCH 1/4] refactor: black --- background_task/admin.py | 43 ++++++++++++++++++++++++++++++++++------ 1 file changed, 37 insertions(+), 6 deletions(-) diff --git a/background_task/admin.py b/background_task/admin.py index a7d6635..9b6d776 100644 --- a/background_task/admin.py +++ b/background_task/admin.py @@ -8,24 +8,55 @@ def inc_priority(modeladmin, request, queryset): for obj in queryset: obj.priority += 1 obj.save() + + inc_priority.short_description = "priority += 1" + def dec_priority(modeladmin, request, queryset): for obj in queryset: obj.priority -= 1 obj.save() + + dec_priority.short_description = "priority -= 1" + class TaskAdmin(admin.ModelAdmin): - display_filter = ['task_name'] - search_fields = ['task_name', 'task_params', ] - list_display = ['task_name', 'task_params', 'run_at', 'priority', 'attempts', 'has_error', 'locked_by', 'locked_by_pid_running', ] + display_filter = ["task_name"] + search_fields = [ + "task_name", + "task_params", + ] + list_display = [ + "task_name", + "task_params", + "run_at", + "priority", + "attempts", + "has_error", + "locked_by", + "locked_by_pid_running", + ] actions = [inc_priority, dec_priority] + class CompletedTaskAdmin(admin.ModelAdmin): - display_filter = ['task_name'] - search_fields = ['task_name', 'task_params', ] - list_display = ['task_name', 'task_params', 'run_at', 'priority', 'attempts', 'has_error', 'locked_by', 'locked_by_pid_running', ] + display_filter = ["task_name"] + search_fields = [ + "task_name", + "task_params", + ] + list_display = [ + "task_name", + "task_params", + "run_at", + "priority", + "attempts", + "has_error", + "locked_by", + "locked_by_pid_running", + ] admin.site.register(Task, TaskAdmin) From c64b4c1e5def805aad824bde752cc133cba338a2 Mon Sep 17 00:00:00 2001 From: PiotrIw Date: Thu, 20 Jun 2024 10:56:49 +0000 Subject: [PATCH 2/4] feat: add admin filters --- background_task/admin.py | 1 + 1 file changed, 1 insertion(+) diff --git a/background_task/admin.py b/background_task/admin.py index 9b6d776..e32397d 100644 --- a/background_task/admin.py +++ b/background_task/admin.py @@ -39,6 +39,7 @@ class TaskAdmin(admin.ModelAdmin): "locked_by_pid_running", ] actions = [inc_priority, dec_priority] + list_filter = ["task_name", "run_at", "priority", "attempts", "has_error"] class CompletedTaskAdmin(admin.ModelAdmin): From 602eaff9179ffa8317568698431ecdda65c4ac05 Mon Sep 17 00:00:00 2001 From: PiotrIw Date: Thu, 20 Jun 2024 10:57:53 +0000 Subject: [PATCH 3/4] feat: add admin filters --- background_task/admin.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/background_task/admin.py b/background_task/admin.py index e32397d..f7e3401 100644 --- a/background_task/admin.py +++ b/background_task/admin.py @@ -39,7 +39,7 @@ class TaskAdmin(admin.ModelAdmin): "locked_by_pid_running", ] actions = [inc_priority, dec_priority] - list_filter = ["task_name", "run_at", "priority", "attempts", "has_error"] + list_filter = ["task_name", "has_error", "attempts", "priority"] class CompletedTaskAdmin(admin.ModelAdmin): @@ -58,6 +58,7 @@ class CompletedTaskAdmin(admin.ModelAdmin): "locked_by", "locked_by_pid_running", ] + list_filter = ["task_name", "has_error", "attempts", "priority"] admin.site.register(Task, TaskAdmin) From 044c64b01f5f42e1addaf61329e4afcc83936873 Mon Sep 17 00:00:00 2001 From: PiotrIw Date: Thu, 20 Jun 2024 10:58:53 +0000 Subject: [PATCH 4/4] chore: version bumpup --- .bumpversion.cfg | 2 +- background_task/__init__.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.bumpversion.cfg b/.bumpversion.cfg index 18c7ae4..a7ad90e 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,7 +1,7 @@ [bumpversion] commit = True tag = True -current_version = 1.3.01 +current_version = 1.3.02 parse = (?P\d+)\.(?P\d+)\.(?P\d+)(\-(?P[a-z]+))? serialize = {major}.{minor}.{patch}-{release} diff --git a/background_task/__init__.py b/background_task/__init__.py index 808f054..158d416 100644 --- a/background_task/__init__.py +++ b/background_task/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -__version__ = "1.3.01" +__version__ = "1.3.02" default_app_config = "background_task.apps.BackgroundTasksAppConfig"