0001-misc-use-an-afterjob-to-update-formdatas-when-a-work.patch
tests/test_workflows.py | ||
---|---|---|
3390 | 3390 | |
3391 | 3391 |
def test_workflow_action_condition(two_pubs): |
3392 | 3392 |
pub = two_pubs |
3393 |
pub._set_request(None) # to avoid after jobs |
|
3393 | 3394 |
workflow = Workflow(name='jump condition migration') |
3394 | 3395 |
st1 = workflow.add_status('Status1', 'st1') |
3395 | 3396 |
workflow.store() |
wcs/monkeypatch.py | ||
---|---|---|
46 | 46 |
return _thread_local.publisher.get_request() |
47 | 47 | |
48 | 48 |
def get_response(): |
49 |
return _thread_local.publisher.get_request().response |
|
49 |
return get_request() and _thread_local.publisher.get_request().response
|
|
50 | 50 | |
51 | 51 |
def get_field(name, default=None): |
52 | 52 |
return _thread_local.publisher.get_request().get_field(name, default) |
wcs/workflows.py | ||
---|---|---|
26 | 26 |
import time |
27 | 27 |
import uuid |
28 | 28 | |
29 |
from quixote import get_request, redirect |
|
29 |
from quixote import get_request, get_response, redirect
|
|
30 | 30 | |
31 | 31 |
from qommon import _ |
32 | 32 |
from qommon.misc import C_, get_as_datetime, file_digest, get_foreground_colour |
... | ... | |
345 | 345 |
self.last_modification_user_id = None |
346 | 346 |
StorableObject.store(self) |
347 | 347 | |
348 |
# instruct all related formdefs to update. |
|
349 |
for form in FormDef.select(lambda x: x.workflow_id == self.id, ignore_migration=True): |
|
350 |
form.data_class().rebuild_security() |
|
351 |
if must_update: |
|
352 |
form.rebuild() |
|
348 |
def update(job=None): |
|
349 |
# instruct all related formdefs to update. |
|
350 |
for form in FormDef.select(lambda x: x.workflow_id == self.id, ignore_migration=True): |
|
351 |
form.data_class().rebuild_security() |
|
352 |
if must_update: |
|
353 |
form.rebuild() |
|
354 | ||
355 |
if get_response(): |
|
356 |
get_response().add_after_job( |
|
357 |
N_('Reindexing forms after workflow change'), update) |
|
358 |
else: |
|
359 |
update() |
|
353 | 360 | |
354 | 361 |
@classmethod |
355 | 362 |
def get(cls, id, ignore_errors=False, ignore_migration=False): |
356 |
- |