Rename `Task.page_locked_for_user` to `Task.locked_for_user`

pull/9817/head
Sage Abdullah 2022-12-13 16:25:31 +00:00
rodzic 4d53e40cc6
commit e1c6ae2d2b
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: EB1A33CC51CC0217
3 zmienionych plików z 24 dodań i 7 usunięć

Wyświetl plik

@ -1020,7 +1020,7 @@ Tasks represent stages in a workflow which must be approved for the workflow to
.. automethod:: user_can_unlock
.. automethod:: page_locked_for_user
.. automethod:: locked_for_user
.. automethod:: get_actions

Wyświetl plik

@ -135,7 +135,7 @@ class BasicLock(BaseLock):
class WorkflowLock(BaseLock):
"""
A lock that requires the user to pass the Task.page_locked_for_user test on the given workflow task.
A lock that requires the user to pass the Task.locked_for_user test on the given workflow task.
Can be applied to pages only.
"""
@ -145,7 +145,7 @@ class WorkflowLock(BaseLock):
self.task = task
def for_user(self, user):
return self.task.page_locked_for_user(self.object, user)
return self.task.locked_for_user(self.object, user)
def get_message(self, user):
if self.for_user(user):

Wyświetl plik

@ -90,7 +90,10 @@ from wagtail.signals import (
workflow_submitted,
)
from wagtail.url_routing import RouteResult
from wagtail.utils.deprecation import RemovedInWagtail50Warning
from wagtail.utils.deprecation import (
RemovedInWagtail50Warning,
RemovedInWagtail60Warning,
)
from .audit_log import ( # noqa
BaseLogEntry,
@ -3609,8 +3612,22 @@ class Task(models.Model):
Note that returning False does not remove permissions from users who would otherwise have them."""
return False
def page_locked_for_user(self, obj, user):
"""Returns True if the object should be locked to a given user's edits. This can be used to prevent editing by non-reviewers."""
def locked_for_user(self, obj, user):
"""
Returns True if the object should be locked to a given user's edits.
This can be used to prevent editing by non-reviewers.
.. versionchanged:: 4.2
This method has been renamed from ``page_locked_for_user`` to ``locked_for_user``.
"""
if hasattr(self, "page_locked_for_user"):
warnings.warn(
"Tasks should use .locked_for_user() instead of "
".page_locked_for_user().",
category=RemovedInWagtail60Warning,
stacklevel=2,
)
return self.page_locked_for_user(obj, user)
return False
def user_can_lock(self, obj, user):
@ -3791,7 +3808,7 @@ class GroupApprovalTask(Task):
self.groups.filter(id__in=user.groups.all()).exists() or user.is_superuser
)
def page_locked_for_user(self, obj, user):
def locked_for_user(self, obj, user):
return not (
self.groups.filter(id__in=user.groups.all()).exists() or user.is_superuser
)