Added `AbstractGroupApprovalTask` to simplify customizing behavior

pull/11717/head
John-Scott Atlakson 2024-02-14 12:02:15 -08:00 zatwierdzone przez LB Johnston
rodzic aebdf82387
commit 068c3f2964
4 zmienionych plików z 15 dodań i 3 usunięć

Wyświetl plik

@ -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)

Wyświetl plik

@ -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

Wyświetl plik

@ -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

Wyświetl plik

@ -3616,7 +3616,7 @@ class Workflow(AbstractWorkflow):
pass
class GroupApprovalTask(Task):
class AbstractGroupApprovalTask(Task):
groups = models.ManyToManyField(
Group,
verbose_name=_("groups"),
@ -3698,10 +3698,15 @@ class GroupApprovalTask(Task):
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):
"""