From f955c819d7a3b4cca926d770679f985a3559756e Mon Sep 17 00:00:00 2001 From: John-Scott Atlakson <24574+jsma@users.noreply.github.com> Date: Wed, 14 Feb 2024 12:02:15 -0800 Subject: [PATCH] Added `AbstractGroupApprovalTask` to simplify customizing behavior --- docs/extending/custom_tasks.md | 9 +++++++-- wagtail/models/__init__.py | 7 ++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/docs/extending/custom_tasks.md b/docs/extending/custom_tasks.md index 48b7f7664563..285b0ecdbaf3 100644 --- a/docs/extending/custom_tasks.md +++ b/docs/extending/custom_tasks.md @@ -4,11 +4,16 @@ The Workflow system allows users to create tasks, which represent stages of mode Wagtail provides one built-in task type: `GroupApprovalTask`, which allows any user in specific groups to approve or reject moderation. -However, it is possible to implement your own task types. Instances of your custom task can then be created in the `Tasks` section of the Wagtail Admin. +However, it is possible to implement your own task types. Instances of your custom task can then be created in the `Workflow tasks` section of the Wagtail Admin. ## Task models -All custom tasks must be models inheriting from `wagtailcore.Task`. In this set of examples, we'll set up a task that can be approved by only one specific user. +All custom tasks must be models inheriting from `wagtailcore.Task`. + +If you need to customize the behavior of the built-in `GroupApprovalTask`, create a custom task which inherits from `AbstractGroupApprovalTask` and add your customizations there. +See below for more details on how to customize behavior. + +In this set of examples, we'll set up a task that can be approved by only one specific user. ```python # /models.py diff --git a/wagtail/models/__init__.py b/wagtail/models/__init__.py index 5e453d21430f..03a1dfcec213 100644 --- a/wagtail/models/__init__.py +++ b/wagtail/models/__init__.py @@ -3616,7 +3616,7 @@ class Workflow(AbstractWorkflow): pass -class GroupApprovalTask(Task): +class AbstractGroupApprovalTask(Task): groups = models.ManyToManyField( Group, verbose_name=_("groups"), @@ -3687,10 +3687,15 @@ def get_description(cls): return _("Members of the chosen Wagtail Groups can approve this task") class Meta: + abstract = True verbose_name = _("Group approval task") verbose_name_plural = _("Group approval tasks") +class GroupApprovalTask(AbstractGroupApprovalTask): + pass + + class WorkflowStateQuerySet(models.QuerySet): def active(self): """