0
0
mirror of https://github.com/wagtail/wagtail.git synced 2024-11-29 17:36:49 +01:00

Save revision when restart workflow (#6990)

This commit is contained in:
Ihor Marhitych 2021-04-09 23:41:04 +02:00 committed by Dan Braghis
parent b21557319c
commit deeb771032
3 changed files with 13 additions and 8 deletions

View File

@ -24,6 +24,7 @@ Changelog
* Add support for exporting redirects (Martin Sandström)
* Support slicing on StreamField / StreamBlock values (Matt Westcott)
* Switch Wagtail choosers to use SVG icons instead of font icon (Storm Heg)
* Save revision when restart workflow (Ihor Marhitych)
* Fix: StreamField required status is now consistently handled by the `blank` keyword argument (Matt Westcott)
* Fix: Show 'required' asterisks for blocks inside required StreamFields (Matt Westcott)
* Fix: Make image chooser "Select format" fields translatable (Helen Chapman, Thibaud Colas)

View File

@ -47,6 +47,7 @@ Other features
* Add support for exporting redirects (Martin Sandström)
* Support slicing on StreamField / StreamBlock values (Matt Westcott)
* Switch Wagtail choosers to use SVG icons instead of font icon (Storm Heg)
* Save revision when restart workflow (Ihor Marhitych)
Bug fixes

View File

@ -394,15 +394,18 @@ class EditView(TemplateResponseMixin, ContextMixin, HookResponseMixin, View):
def restart_workflow_action(self):
self.page = self.form.save(commit=False)
self.workflow_state.cancel(user=self.request.user)
# save 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.workflow_state and self.workflow_state.status == WorkflowState.STATUS_NEEDS_CHANGES:
# If the workflow was in the needs changes state, resume the existing workflow on submission
self.workflow_state.resume(self.request.user)
else:
# Otherwise start a new workflow
workflow = self.page.get_workflow()
workflow.start(self.page, self.request.user)
# cancel workflow
self.workflow_state.cancel(user=self.request.user)
# start new workflow
workflow = self.page.get_workflow()
workflow.start(self.page, self.request.user)
message = _(
"Workflow on page '{0}' has been restarted."