0
0
mirror of https://github.com/wagtail/wagtail.git synced 2024-12-01 11:41:20 +01:00

Safely access Page-specific attributes in WorkflowState methods

This commit is contained in:
Sage Abdullah 2022-12-19 11:23:43 +00:00
parent dcb7949c59
commit c8463e8642
No known key found for this signature in database
GPG Key ID: EB1A33CC51CC0217

View File

@ -4044,8 +4044,12 @@ class WorkflowState(models.Model):
self.status = self.STATUS_IN_PROGRESS
self.save()
instance = self.content_object
if isinstance(instance, Page):
instance = self.content_object.specific
log(
instance=self.content_object.specific,
instance=instance,
action="wagtail.workflow.resume",
data={
"workflow": {
@ -4069,7 +4073,7 @@ class WorkflowState(models.Model):
return False
return (
user == self.requested_by
or user == self.content_object.owner
or user == getattr(self.content_object, "owner", None)
or (
self.current_task_state
and self.current_task_state.status
@ -4151,8 +4155,12 @@ class WorkflowState(models.Model):
self.status = self.STATUS_CANCELLED
self.save()
instance = self.content_object
if isinstance(instance, Page):
instance = self.content_object.specific
log(
instance=self.content_object.specific,
instance=instance,
action="wagtail.workflow.cancel",
data={
"workflow": {