backoffice: do not remap to first status by default (#14289) #600
|
@ -234,6 +234,8 @@ def test_card_workflow_change(pub):
|
|||
== 'http://example.net/backoffice/cards/1/workflow-status-remapping?new=%s' % workflow.id
|
||||
)
|
||||
resp = resp.follow()
|
||||
resp.form['mapping-recorded'] = 'plop'
|
||||
resp.form['mapping-deleted'] = 'plop'
|
||||
resp = resp.form.submit('submit')
|
||||
assert AfterJob.count() == 1
|
||||
job = AfterJob.select()[0]
|
||||
|
@ -251,6 +253,7 @@ def test_card_workflow_change(pub):
|
|||
== 'http://example.net/backoffice/cards/1/workflow-status-remapping?new=%s' % '_carddef_default'
|
||||
)
|
||||
resp = resp.follow()
|
||||
resp.form['mapping-1'] = 'Recorded'
|
||||
resp = resp.form.submit('submit').follow()
|
||||
|
||||
|
||||
|
|
|
@ -740,10 +740,17 @@ def test_form_workflow_remapping(pub):
|
|||
resp = resp.forms[0].submit('submit')
|
||||
assert resp.location == 'http://example.net/backoffice/forms/1/workflow-status-remapping?new=2'
|
||||
resp = resp.follow()
|
||||
assert resp.pyquery('.SingleSelectWidget').length == 5
|
||||
resp = resp.forms[0].submit()
|
||||
assert resp.pyquery('.SingleSelectWidget.widget-with-error').length == 4
|
||||
for status in Workflow.get_default_workflow().possible_status:
|
||||
assert resp.forms[0]['mapping-%s' % status.id]
|
||||
assert resp.forms[0]['mapping-%s' % status.id].options[0][0] == '' # empty option
|
||||
# there's only one possible new status
|
||||
assert len(resp.forms[0]['mapping-%s' % status.id].options) == 1
|
||||
assert len([x for x in resp.forms[0]['mapping-%s' % status.id].options if x[0]]) == 1
|
||||
if not resp.forms[0]['mapping-%s' % status.id].value:
|
||||
# set to first status
|
||||
resp.forms[0]['mapping-%s' % status.id] = resp.forms[0]['mapping-%s' % status.id].options[1][0]
|
||||
assert data_class.get(formdata1.id).status == 'wf-new'
|
||||
assert data_class.get(formdata2.id).status == 'draft'
|
||||
assert data_class.get(formdata3.id).status == 'wf-1'
|
||||
|
@ -780,9 +787,12 @@ def test_form_workflow_remapping(pub):
|
|||
assert resp.location == 'http://example.net/backoffice/forms/1/workflow-status-remapping?new=3'
|
||||
resp = resp.follow()
|
||||
for status in workflow2.possible_status:
|
||||
assert resp.forms[0]['mapping-%s' % status.id]
|
||||
assert resp.forms[0]['mapping-%s' % status.id].options[0][0] == '' # empty option
|
||||
# there are two status
|
||||
assert len(resp.forms[0]['mapping-%s' % status.id].options) == 2
|
||||
assert len([x for x in resp.forms[0]['mapping-%s' % status.id].options if x[0]]) == 2
|
||||
if not resp.forms[0]['mapping-%s' % status.id].value:
|
||||
# set to first status
|
||||
resp.forms[0]['mapping-%s' % status.id] = resp.forms[0]['mapping-%s' % status.id].options[1][0]
|
||||
resp = resp.forms[0].submit()
|
||||
assert data_class.get(formdata1.id).status == 'wf-finished'
|
||||
assert data_class.get(formdata2.id).status == 'draft'
|
||||
|
|
|
@ -1145,18 +1145,19 @@ class FormDefPage(Directory):
|
|||
new_workflow = Workflow.get(get_request().form.get('new'))
|
||||
if get_request().get_method() == 'GET':
|
||||
get_request().form = None # do not be considered submitted already
|
||||
new_workflow_status = [(x.id, x.name) for x in new_workflow.possible_status]
|
||||
new_workflow_status = [('', '')] + [(x.id, x.name) for x in new_workflow.possible_status]
|
||||
form = Form(enctype='multipart/form-data')
|
||||
for status in self.formdef.workflow.possible_status:
|
||||
default = status.id
|
||||
if default not in [x.id for x in new_workflow.possible_status]:
|
||||
default = new_workflow_status[0]
|
||||
default = ''
|
||||
form.add(
|
||||
SingleSelectWidget,
|
||||
'mapping-%s' % status.id,
|
||||
title=status.name,
|
||||
value=default,
|
||||
options=new_workflow_status,
|
||||
required=True,
|
||||
)
|
||||
|
||||
form.add_submit('submit', _('Submit'))
|
||||
|
|
Loading…
Reference in New Issue