0001-workflows-clean-variables-formdef-when-it-has-no-fie.patch
tests/admin_pages/test_workflow.py | ||
---|---|---|
1573 | 1573 |
assert Workflow.get(1).variables_formdef.fields[0].varname == 'xxx' |
1574 | 1574 | |
1575 | 1575 | |
1576 |
def test_workflows_variables_delete(pub): |
|
1577 |
create_superuser(pub) |
|
1578 | ||
1579 |
Workflow.wipe() |
|
1580 |
workflow = Workflow(name='foo') |
|
1581 |
workflow.store() |
|
1582 | ||
1583 |
app = login(get_app(pub)) |
|
1584 |
resp = app.get('http://example.net/backoffice/workflows/%s/variables/fields/' % workflow.id) |
|
1585 | ||
1586 |
resp.forms[0]['label'] = 'foobar' |
|
1587 |
resp.forms[0]['type'] = 'string' |
|
1588 |
resp = resp.forms[0].submit() |
|
1589 |
resp = resp.follow() |
|
1590 | ||
1591 |
assert len(Workflow.get(workflow.id).variables_formdef.fields) == 1 |
|
1592 |
resp = resp.click(href=resp.pyquery('#fields-list .remove a').attr.href) |
|
1593 |
assert 'You are about to remove the "foobar" field.' in resp.text |
|
1594 |
resp = resp.forms[0].submit() |
|
1595 |
assert Workflow.get(workflow.id).variables_formdef is None |
|
1596 | ||
1597 | ||
1576 | 1598 |
def test_workflows_export_to_model_action_display(pub): |
1577 | 1599 |
create_superuser(pub) |
1578 | 1600 |
wcs/workflows.py | ||
---|---|---|
439 | 439 |
if hasattr(field, 'widget_class'): |
440 | 440 |
if not field.varname: |
441 | 441 |
field.varname = misc.simplify(field.label, space='_') |
442 |
self.workflow.variables_formdef = self |
|
442 |
self.workflow.variables_formdef = self if self.fields else None
|
|
443 | 443 |
self.workflow.store(comment=comment, *args, **kwargs) |
444 | 444 | |
445 | 445 | |
446 |
- |