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

Check for commenting changes in workflow actions too

One of them checks has_content_changes before creating a revision. Think
it's worth checking this in all variants for consitency, and also so we
don't forget to update the logic if we ever move comments out of
content in the future.
This commit is contained in:
Karl Hobley 2021-05-04 11:59:19 +01:00 committed by Karl Hobley
parent 935ad479db
commit 8be72de524

View File

@ -462,7 +462,7 @@ class EditView(TemplateResponseMixin, ContextMixin, HookResponseMixin, View):
self.add_save_confirmation_message()
if 'comments' in self.form.formsets:
if self.has_content_changes and 'comments' in self.form.formsets:
changes = self.get_commenting_changes()
self.log_commenting_changes(changes, revision)
self.send_commenting_notifications(changes)
@ -498,7 +498,7 @@ class EditView(TemplateResponseMixin, ContextMixin, HookResponseMixin, View):
previous_revision=(self.previous_revision if self.is_reverting else None)
)
if 'comments' in self.form.formsets:
if self.has_content_changes and 'comments' in self.form.formsets:
changes = self.get_commenting_changes()
self.log_commenting_changes(changes, revision)
self.send_commenting_notifications(changes)
@ -580,7 +580,7 @@ class EditView(TemplateResponseMixin, ContextMixin, HookResponseMixin, View):
previous_revision=(self.previous_revision if self.is_reverting else None)
)
if 'comments' in self.form.formsets:
if self.has_content_changes and 'comments' in self.form.formsets:
changes = self.get_commenting_changes()
self.log_commenting_changes(changes, revision)
self.send_commenting_notifications(changes)
@ -616,12 +616,17 @@ class EditView(TemplateResponseMixin, ContextMixin, HookResponseMixin, View):
self.subscription.save()
# save revision
self.page.save_revision(
revision = self.page.save_revision(
user=self.request.user,
log_action=True, # Always log the new revision on edit
previous_revision=(self.previous_revision if self.is_reverting else None)
)
if self.has_content_changes and 'comments' in self.form.formsets:
changes = self.get_commenting_changes()
self.log_commenting_changes(changes, revision)
self.send_commenting_notifications(changes)
# cancel workflow
self.workflow_state.cancel(user=self.request.user)
# start new workflow
@ -652,12 +657,17 @@ class EditView(TemplateResponseMixin, ContextMixin, HookResponseMixin, View):
if self.has_content_changes:
# Save revision
self.page.save_revision(
revision = self.page.save_revision(
user=self.request.user,
log_action=True, # Always log the new revision on edit
previous_revision=(self.previous_revision if self.is_reverting else None)
)
if 'comments' in self.form.formsets:
changes = self.get_commenting_changes()
self.log_commenting_changes(changes, revision)
self.send_commenting_notifications(changes)
extra_workflow_data_json = self.request.POST.get('workflow-action-extra-data', '{}')
extra_workflow_data = json.loads(extra_workflow_data_json)
self.page.current_workflow_task.on_action(self.page.current_workflow_task_state, self.request.user, self.workflow_action, **extra_workflow_data)
@ -677,12 +687,17 @@ class EditView(TemplateResponseMixin, ContextMixin, HookResponseMixin, View):
self.subscription.save()
# Save revision
self.page.save_revision(
revision = self.page.save_revision(
user=self.request.user,
log_action=True, # Always log the new revision on edit
previous_revision=(self.previous_revision if self.is_reverting else None)
)
if self.has_content_changes and 'comments' in self.form.formsets:
changes = self.get_commenting_changes()
self.log_commenting_changes(changes, revision)
self.send_commenting_notifications(changes)
# Notifications
self.add_cancel_workflow_confirmation_message()