0001-formdefs-provide-both-id-and-text-for-item-fields-in.patch
tests/test_formdef.py | ||
---|---|---|
12 | 12 |
from wcs import formdef |
13 | 13 |
from wcs.formdef import FormDef |
14 | 14 |
from wcs.workflows import Workflow |
15 |
from wcs.fields import StringField, FileField, DateField |
|
15 |
from wcs.fields import StringField, FileField, DateField, ItemField
|
|
16 | 16 | |
17 | 17 |
from utilities import create_temporary_pub |
18 | 18 | |
... | ... | |
106 | 106 |
from wcs.workflows import WorkflowVariablesFieldsFormDef |
107 | 107 |
wf = Workflow(name='variables') |
108 | 108 |
wf.variables_formdef = WorkflowVariablesFieldsFormDef(workflow=wf) |
109 |
wf.variables_formdef.fields.append( |
|
110 |
StringField(label='Test', type='string', varname='foo')) |
|
109 |
wf.variables_formdef.fields = [ |
|
110 |
StringField(id='1', label='Test', type='string', varname='foo'), |
|
111 |
ItemField(id='2', label='Test Liste', type='item', varname='bar'), |
|
112 |
] |
|
111 | 113 |
wf.store() |
112 | 114 |
formdef.workflow_id = wf.id |
113 | 115 | |
... | ... | |
117 | 119 |
assert 'form_option_foo' in formdef.get_substitution_variables() |
118 | 120 |
assert formdef.get_substitution_variables()['form_option_foo'] == 'bar' |
119 | 121 | |
122 |
formdef.workflow_options = {'bar': 'bar', 'bar_display': 'Bar'} |
|
123 |
assert formdef.get_substitution_variables()['form_option_bar'] == 'Bar' |
|
124 |
assert formdef.get_substitution_variables()['form_option_bar_raw'] == 'bar' |
|
125 | ||
120 | 126 |
def test_schema_with_date_variable(): |
121 | 127 |
FormDef.wipe() |
122 | 128 |
formdef = FormDef() |
wcs/formdef.py | ||
---|---|---|
372 | 372 |
continue |
373 | 373 |
option_name = 'form_option_' + field.varname |
374 | 374 |
variables[option_name] = self.workflow_options.get(field.varname) |
375 |
if field.store_display_value: |
|
376 |
if '%s_display' % field.varname in self.workflow_options: |
|
377 |
variables[option_name + '_raw'] = variables[option_name] |
|
378 |
variables[option_name] = self.workflow_options.get( |
|
379 |
'%s_display' % field.varname) |
|
375 | 380 |
if field.store_structured_value: |
376 | 381 |
if '%s_structured' % field.varname in self.workflow_options: |
377 | 382 |
variables[option_name + '_structured'] = self.workflow_options.get( |
378 |
- |