Skip to content

Commit

Permalink
Added AbstractGroupApprovalTask to simplify customizing behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
jsma authored and lb- committed Mar 13, 2024
1 parent aebdf82 commit 068c3f2
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ Changelog
* Add API support for a redirects (contrib) endpoint (Rohit Sharma, Jaap Roes, Andreas Donig)
* Add the default ability for all `SnippetViewSet` & `ModelViewSet` to support being copied (Shlomo Markowitz)
* Support dynamic Wagtail guide links in the admin that are based on the running version of Wagtail (Tidiane Dia)
* Added `AbstractGroupApprovalTask` to simplify customizing behavior of custom `Task` models (John-Scott Atlakson)
* Fix: Update system check for overwriting storage backends to recognize the `STORAGES` setting introduced in Django 4.2 (phijma-leukeleu)
* Fix: Prevent password change form from raising a validation error when browser autocomplete fills in the "Old password" field (Chiemezuo Akujobi)
* Fix: Ensure that the legacy dropdown options, when closed, do not get accidentally clicked by other interactions on wide viewports (CheesyPhoenix, Christer Jensen)
Expand Down
9 changes: 7 additions & 2 deletions docs/extending/custom_tasks.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
# <project>/models.py
Expand Down
1 change: 1 addition & 0 deletions docs/releases/6.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ depth: 1
* Implement new universal listings design for image listing view (Sage Abdullah)
* Implement new universal listings design for document listing view (Sage Abdullah)
* Implement new universal listings design for site and locale listing views (Sage Abdullah)
* Added `AbstractGroupApprovalTask` to simplify [customizing behavior of custom `Task` models](../extending/custom_tasks) (John-Scott Atlakson)


### Bug fixes
Expand Down
7 changes: 6 additions & 1 deletion wagtail/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3616,7 +3616,7 @@ class Workflow(AbstractWorkflow):
pass


class GroupApprovalTask(Task):
class AbstractGroupApprovalTask(Task):
groups = models.ManyToManyField(
Group,
verbose_name=_("groups"),
Expand Down Expand Up @@ -3698,10 +3698,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):
"""
Expand Down

0 comments on commit 068c3f2

Please sign in to comment.