misc: use an afterjob to update formdatas when a workflow is changed (#23918)
This commit is contained in:
parent
4dc3d6ea3a
commit
e7dac1590c
|
@ -3390,6 +3390,7 @@ def test_workflow_jump_condition_migration(pub):
|
|||
|
||||
def test_workflow_action_condition(two_pubs):
|
||||
pub = two_pubs
|
||||
pub._set_request(None) # to avoid after jobs
|
||||
workflow = Workflow(name='jump condition migration')
|
||||
st1 = workflow.add_status('Status1', 'st1')
|
||||
workflow.store()
|
||||
|
|
|
@ -46,7 +46,7 @@ def get_request():
|
|||
return _thread_local.publisher.get_request()
|
||||
|
||||
def get_response():
|
||||
return _thread_local.publisher.get_request().response
|
||||
return get_request() and _thread_local.publisher.get_request().response
|
||||
|
||||
def get_field(name, default=None):
|
||||
return _thread_local.publisher.get_request().get_field(name, default)
|
||||
|
|
|
@ -26,7 +26,7 @@ import sys
|
|||
import time
|
||||
import uuid
|
||||
|
||||
from quixote import get_request, redirect
|
||||
from quixote import get_request, get_response, redirect
|
||||
|
||||
from qommon import _
|
||||
from qommon.misc import C_, get_as_datetime, file_digest, get_foreground_colour
|
||||
|
@ -345,11 +345,18 @@ class Workflow(StorableObject):
|
|||
self.last_modification_user_id = None
|
||||
StorableObject.store(self)
|
||||
|
||||
# instruct all related formdefs to update.
|
||||
for form in FormDef.select(lambda x: x.workflow_id == self.id, ignore_migration=True):
|
||||
form.data_class().rebuild_security()
|
||||
if must_update:
|
||||
form.rebuild()
|
||||
def update(job=None):
|
||||
# instruct all related formdefs to update.
|
||||
for form in FormDef.select(lambda x: x.workflow_id == self.id, ignore_migration=True):
|
||||
form.data_class().rebuild_security()
|
||||
if must_update:
|
||||
form.rebuild()
|
||||
|
||||
if get_response():
|
||||
get_response().add_after_job(
|
||||
N_('Reindexing forms after workflow change'), update)
|
||||
else:
|
||||
update()
|
||||
|
||||
@classmethod
|
||||
def get(cls, id, ignore_errors=False, ignore_migration=False):
|
||||
|
|
Loading…
Reference in New Issue