kopia lustrzana https://github.com/wagtail/wagtail
Rename `Task.page_locked_for_user` to `Task.locked_for_user`
rodzic
4d53e40cc6
commit
e1c6ae2d2b
|
@ -1020,7 +1020,7 @@ Tasks represent stages in a workflow which must be approved for the workflow to
|
||||||
|
|
||||||
.. automethod:: user_can_unlock
|
.. automethod:: user_can_unlock
|
||||||
|
|
||||||
.. automethod:: page_locked_for_user
|
.. automethod:: locked_for_user
|
||||||
|
|
||||||
.. automethod:: get_actions
|
.. automethod:: get_actions
|
||||||
|
|
||||||
|
|
|
@ -135,7 +135,7 @@ class BasicLock(BaseLock):
|
||||||
|
|
||||||
class WorkflowLock(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.
|
Can be applied to pages only.
|
||||||
"""
|
"""
|
||||||
|
@ -145,7 +145,7 @@ class WorkflowLock(BaseLock):
|
||||||
self.task = task
|
self.task = task
|
||||||
|
|
||||||
def for_user(self, user):
|
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):
|
def get_message(self, user):
|
||||||
if self.for_user(user):
|
if self.for_user(user):
|
||||||
|
|
|
@ -90,7 +90,10 @@ from wagtail.signals import (
|
||||||
workflow_submitted,
|
workflow_submitted,
|
||||||
)
|
)
|
||||||
from wagtail.url_routing import RouteResult
|
from wagtail.url_routing import RouteResult
|
||||||
from wagtail.utils.deprecation import RemovedInWagtail50Warning
|
from wagtail.utils.deprecation import (
|
||||||
|
RemovedInWagtail50Warning,
|
||||||
|
RemovedInWagtail60Warning,
|
||||||
|
)
|
||||||
|
|
||||||
from .audit_log import ( # noqa
|
from .audit_log import ( # noqa
|
||||||
BaseLogEntry,
|
BaseLogEntry,
|
||||||
|
@ -3609,8 +3612,22 @@ class Task(models.Model):
|
||||||
Note that returning False does not remove permissions from users who would otherwise have them."""
|
Note that returning False does not remove permissions from users who would otherwise have them."""
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def page_locked_for_user(self, obj, user):
|
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."""
|
"""
|
||||||
|
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
|
return False
|
||||||
|
|
||||||
def user_can_lock(self, obj, user):
|
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
|
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 (
|
return not (
|
||||||
self.groups.filter(id__in=user.groups.all()).exists() or user.is_superuser
|
self.groups.filter(id__in=user.groups.all()).exists() or user.is_superuser
|
||||||
)
|
)
|
||||||
|
|
Ładowanie…
Reference in New Issue