workflows: run field migrations in form workflow action (#32459)
This commit is contained in:
parent
de0a999ac1
commit
4d72f6ca62
|
@ -2219,6 +2219,27 @@ def test_display_form_and_comment(pub):
|
|||
assert 'Test' in str(form.widgets[0].render())
|
||||
assert '<textarea' in str(form.widgets[1].render())
|
||||
|
||||
def test_display_form_migration(pub):
|
||||
wf = Workflow(name='status')
|
||||
st1 = wf.add_status('Status1', 'st1')
|
||||
|
||||
display_form = FormWorkflowStatusItem()
|
||||
display_form.id = '_x'
|
||||
display_form.varname = 'xxx'
|
||||
display_form.formdef = WorkflowFormFieldsFormDef(item=display_form)
|
||||
display_form.formdef.fields = [
|
||||
ItemField(id='1', label='Test', type='item')
|
||||
]
|
||||
st1.items.append(display_form)
|
||||
display_form.parent = st1
|
||||
|
||||
display_form.formdef.fields[0].show_as_radio = True
|
||||
wf.store()
|
||||
|
||||
wf = Workflow.get(wf.id)
|
||||
assert wf.possible_status[0].items[0].formdef.fields[0].display_mode == 'radio'
|
||||
|
||||
|
||||
def test_choice_button_no_label(pub):
|
||||
role = Role(name='bar1')
|
||||
role.store()
|
||||
|
|
|
@ -109,6 +109,13 @@ class FormWorkflowStatusItem(WorkflowStatusItem):
|
|||
def get_parameters(self):
|
||||
return ('by', 'varname', 'condition')
|
||||
|
||||
def migrate(self):
|
||||
changed = False
|
||||
if self.formdef and self.formdef.fields:
|
||||
for field in self.formdef.fields:
|
||||
changed |= field.migrate()
|
||||
return changed
|
||||
|
||||
def export_to_xml(self, charset, include_id=False):
|
||||
item = WorkflowStatusItem.export_to_xml(self, charset, include_id=include_id)
|
||||
if not hasattr(self, 'formdef') or not self.formdef or not self.formdef.fields:
|
||||
|
|
Loading…
Reference in New Issue