0001-workflows-skip-non-widget-fields-in-set-backoffice-f.patch
tests/test_admin_pages.py | ||
---|---|---|
1675 | 1675 |
resp = resp.forms[0].submit() |
1676 | 1676 |
resp = resp.follow() |
1677 | 1677 | |
1678 |
resp = resp.click('Set Backoffice Fields') |
|
1679 | ||
1680 | 1678 |
# add a second field |
1681 | 1679 |
resp = app.get('/backoffice/workflows/1/') |
1682 | 1680 |
resp = resp.click(href='backoffice-fields/', index=0) |
... | ... | |
1692 | 1690 |
assert workflow.backoffice_fields_formdef.fields[0].id == 'bo1' |
1693 | 1691 |
assert workflow.backoffice_fields_formdef.fields[1].id == 'bo2' |
1694 | 1692 | |
1693 |
# add a title field |
|
1694 |
resp = app.get('/backoffice/workflows/1/backoffice-fields/fields/') |
|
1695 |
resp.forms[0]['label'] = 'foobar3' |
|
1696 |
resp.forms[0]['type'] = 'Title' |
|
1697 |
resp = resp.form.submit() |
|
1698 |
workflow = Workflow.get(workflow.id) |
|
1699 |
assert len(workflow.backoffice_fields_formdef.fields) == 3 |
|
1700 |
assert workflow.backoffice_fields_formdef.fields[2].id == 'bo3' |
|
1701 | ||
1702 |
# check backoffice fields are available in set backoffice fields action |
|
1703 |
resp = app.get('/backoffice/workflows/1/') |
|
1704 |
resp = resp.click('baz') # status |
|
1705 |
resp = resp.click('Set Backoffice Fields') |
|
1706 |
options = [x[2] for x in resp.form['fields$element0$field_id'].options] |
|
1707 |
assert '' in options |
|
1708 |
assert 'foobar' in options |
|
1709 |
assert 'foobar2' in options |
|
1710 |
assert 'foobar3' not in options |
|
1711 | ||
1712 |
resp.form['fields$element0$field_id'] = 'bo1' |
|
1713 |
resp.form['fields$element0$value'] = 'Hello' |
|
1714 |
resp = resp.form.submit('submit') |
|
1715 |
workflow = Workflow.get(workflow.id) |
|
1716 |
assert workflow.possible_status[0].items[0].fields == [{'field_id': 'bo1', 'value': 'Hello'}] |
|
1717 | ||
1695 | 1718 |
def test_workflows_functions(pub): |
1696 | 1719 |
create_superuser(pub) |
1697 | 1720 |
create_role() |
wcs/wf/backoffice_fields.py | ||
---|---|---|
21 | 21 | |
22 | 22 |
from qommon import get_logger |
23 | 23 |
from qommon.form import WidgetListAsTable, CompositeWidget, SingleSelectWidget, ComputedExpressionWidget |
24 |
from wcs.fields import WidgetField |
|
24 | 25 |
from wcs.workflows import XmlSerialisable, WorkflowStatusItem, register_item_class |
25 | 26 |
from wcs.wf.profile import FieldNode |
26 | 27 | |
... | ... | |
32 | 33 |
value = {} |
33 | 34 | |
34 | 35 |
fields = [('', '', '')] |
35 |
fields.extend([(x.id, x.label, x.id) for x in workflow.get_backoffice_fields()]) |
|
36 |
for field in workflow.get_backoffice_fields(): |
|
37 |
if not issubclass(field.__class__, WidgetField): |
|
38 |
continue |
|
39 |
fields.append((field.id, field.label, field.id)) |
|
36 | 40 |
self.add(SingleSelectWidget, name='field_id', title=_('Field'), |
37 | 41 |
value=value.get('field_id'), |
38 | 42 |
options=fields, **kwargs) |
39 |
- |