workflow: do not overwrite parent submission_context (#69048)
gitea-wip/wcs/pipeline/head Build started...
Details
gitea-wip/wcs/pipeline/head Build started...
Details
This commit is contained in:
parent
b1a905bf98
commit
e9a03ffacf
|
@ -353,3 +353,42 @@ def test_create_formdata_card_item_mapping(pub):
|
|||
assert pub.loggederror_class.count() == 1
|
||||
error = pub.loggederror_class.select()[0]
|
||||
assert error.exception_message == "unknown card value ('XXX')"
|
||||
|
||||
|
||||
def test_create_formdata_does_not_overwrite_initial_submission_context(pub):
|
||||
FormDef.wipe()
|
||||
pub.tracking_code_class.wipe()
|
||||
|
||||
wf = Workflow(name='create-formdata')
|
||||
wf.possible_status = Workflow.get_default_workflow().possible_status[:]
|
||||
create = wf.possible_status[1].add_action('create_formdata', id='_create', prepend=True)
|
||||
create.label = 'create a new linked form'
|
||||
create.varname = 'resubmitted'
|
||||
create.keep_submission_context = True
|
||||
create.map_fields_by_varname = True
|
||||
# prevent recursive execution of create_formdata
|
||||
create.condition = {
|
||||
'type': 'django',
|
||||
'value': 'not form_submission_context_orig_formdata_id',
|
||||
}
|
||||
wf.store()
|
||||
|
||||
target_formdef = FormDef()
|
||||
target_formdef.name = 'target form'
|
||||
target_formdef.fields = []
|
||||
target_formdef.workflow_id = wf.id
|
||||
target_formdef.store()
|
||||
|
||||
create.formdef_slug = target_formdef.url_name
|
||||
wf.store()
|
||||
|
||||
formdata = target_formdef.data_class()()
|
||||
formdata.data = {}
|
||||
formdata.submission_context = {'a': 'b'}
|
||||
formdata.just_created()
|
||||
|
||||
assert target_formdef.data_class().count() == 0
|
||||
del target_formdef._workflow
|
||||
formdata.perform_workflow()
|
||||
assert target_formdef.data_class().count() == 2
|
||||
assert formdata.submission_context == {'a': 'b'}
|
||||
|
|
|
@ -564,7 +564,7 @@ class CreateFormdataWorkflowStatusItem(WorkflowStatusItem):
|
|||
self.assign_user(dest=new_formdata, src=formdata)
|
||||
|
||||
if self.keep_submission_context:
|
||||
new_formdata.submission_context = formdata.submission_context or {}
|
||||
new_formdata.submission_context = (formdata.submission_context or {}).copy()
|
||||
new_formdata.submission_channel = formdata.submission_channel
|
||||
new_formdata.submission_agent_id = formdata.submission_agent_id
|
||||
else:
|
||||
|
|
|
@ -80,7 +80,7 @@ class ResubmitWorkflowStatusItem(WorkflowStatusItem):
|
|||
new_formdata = formdef.data_class()()
|
||||
new_formdata.status = 'draft'
|
||||
new_formdata.user_id = formdata.user_id
|
||||
new_formdata.submission_context = formdata.submission_context
|
||||
new_formdata.submission_context = (formdata.submission_context or {}).copy()
|
||||
new_formdata.submission_channel = formdata.submission_channel
|
||||
new_formdata.backoffice_submission = get_request().is_in_backoffice()
|
||||
if not new_formdata.submission_context:
|
||||
|
|
Loading…
Reference in New Issue