wf: add condition on create formdata and carddata actions (#40842)
This commit is contained in:
parent
3ca4c15041
commit
649976aedd
|
@ -4542,6 +4542,14 @@ def test_create_formdata(pub):
|
|||
assert any('form_var_toto_string' in (error.exception_message or '') for error in errors)
|
||||
assert any('Missing field' in error.summary for error in errors)
|
||||
|
||||
create.condition = {'type': 'python', 'value': '1 == 2'}
|
||||
wf.store()
|
||||
del source_formdef._workflow
|
||||
target_formdef.data_class().wipe()
|
||||
assert target_formdef.data_class().count() == 0
|
||||
formdata.perform_workflow()
|
||||
assert target_formdef.data_class().count() == 0
|
||||
|
||||
|
||||
def test_create_carddata(pub):
|
||||
CardDef.wipe()
|
||||
|
@ -4616,3 +4624,11 @@ def test_create_carddata(pub):
|
|||
carddata = carddef.data_class().get(id=2)
|
||||
assert carddata.get_substitution_variables()['form_var_clist'] == 'item1'
|
||||
assert carddata.get_substitution_variables()['form_var_cdate'] == today
|
||||
|
||||
create.condition = {'type': 'python', 'value': '1 == 2'}
|
||||
wf.store()
|
||||
del formdef._workflow
|
||||
carddef.data_class().wipe()
|
||||
assert carddef.data_class().count() == 0
|
||||
formdata.perform_workflow()
|
||||
assert carddef.data_class().count() == 0
|
||||
|
|
|
@ -46,7 +46,7 @@ class CreateCarddataWorkflowStatusItem(CreateFormdataWorkflowStatusItem):
|
|||
return get_publisher().has_site_option('studio')
|
||||
|
||||
def get_parameters(self):
|
||||
return ('formdef_slug', 'mappings', 'keep_user', 'varname')
|
||||
return ('formdef_slug', 'mappings', 'keep_user', 'varname', 'condition')
|
||||
|
||||
|
||||
register_item_class(CreateCarddataWorkflowStatusItem)
|
||||
|
|
|
@ -292,7 +292,7 @@ class CreateFormdataWorkflowStatusItem(WorkflowStatusItem):
|
|||
|
||||
def get_parameters(self):
|
||||
return ('draft', 'formdef_slug', 'map_fields_by_varname', 'mappings', 'backoffice_submission',
|
||||
'keep_user', 'keep_submission_context', 'varname', 'attach_to_history')
|
||||
'keep_user', 'keep_submission_context', 'varname', 'attach_to_history', 'condition')
|
||||
|
||||
def get_line_details(self):
|
||||
if not (self.mappings or self.map_fields_by_varname):
|
||||
|
|
Loading…
Reference in New Issue