0001-snapshots-do-not-fail-on-workflow-import-error-53960.patch
tests/test_snapshots.py | ||
---|---|---|
472 | 472 |
assert not hasattr(Workflow.get(workflow.id), 'snapshot_object') |
473 | 473 | |
474 | 474 | |
475 |
def test_workflow_snapshot_restore_with_import_error(pub): |
|
476 |
create_superuser(pub) |
|
477 |
create_role(pub) |
|
478 |
app = login(get_app(pub)) |
|
479 | ||
480 |
Workflow.wipe() |
|
481 |
wf = Workflow(name='status') |
|
482 |
st1 = wf.add_status('Status1', 'st1') |
|
483 | ||
484 |
display_form = FormWorkflowStatusItem() |
|
485 |
display_form.id = '_x' |
|
486 |
display_form.varname = 'xxx' |
|
487 |
display_form.formdef = WorkflowFormFieldsFormDef(item=display_form) |
|
488 |
display_form.formdef.fields = [ |
|
489 |
ItemField(id='1', label='Test', type='item', data_source={'type': 'unknown'}) |
|
490 |
] |
|
491 |
st1.items.append(display_form) |
|
492 |
display_form.parent = st1 |
|
493 |
wf.store() |
|
494 | ||
495 |
assert pub.snapshot_class.count() == 1 |
|
496 |
snapshot = pub.snapshot_class.select_object_history(wf)[0] |
|
497 |
resp = app.get('/backoffice/workflows/%s/history/%s/restore' % (wf.id, snapshot.id)) |
|
498 |
resp = resp.form.submit('submit') |
|
499 |
assert 'Can not restore snapshot (Unknown datasources [unknown])' in resp |
|
500 | ||
501 | ||
475 | 502 |
def test_workflow_with_model_snapshot_browse(pub): |
476 | 503 |
create_superuser(pub) |
477 | 504 |
create_role(pub) |
wcs/backoffice/snapshots.py | ||
---|---|---|
26 | 26 |
from wcs.qommon import _, errors, misc, template |
27 | 27 |
from wcs.qommon.backoffice.menu import html_top |
28 | 28 |
from wcs.qommon.form import Form, RadiobuttonsWidget, StringWidget |
29 |
from wcs.workflows import Workflow |
|
29 |
from wcs.workflows import Workflow, WorkflowImportError
|
|
30 | 30 |
from wcs.wscalls import NamedWsCall |
31 | 31 | |
32 | 32 | |
... | ... | |
138 | 138 |
if form.get_submit() == 'submit': |
139 | 139 |
try: |
140 | 140 |
self.snapshot.restore(as_new=bool(action.parse() == 'as-new')) |
141 |
except FormdefImportError as e:
|
|
141 |
except (FormdefImportError, WorkflowImportError) as e:
|
|
142 | 142 |
reason = _(e.msg) % e.msg_args |
143 | 143 |
if e.details: |
144 | 144 |
reason += ' [%s]' % e.details |
145 |
- |