workflows: fix status reassignment after deletion (#54493)
This commit is contained in:
parent
77dfc9411a
commit
e1620ad103
|
@ -270,6 +270,63 @@ def test_workflows_delete_status(pub):
|
||||||
resp = resp.follow()
|
resp = resp.follow()
|
||||||
|
|
||||||
|
|
||||||
|
def test_workflows_delete_status_reassign(pub):
|
||||||
|
create_superuser(pub)
|
||||||
|
Workflow.wipe()
|
||||||
|
workflow = Workflow(name='foo')
|
||||||
|
wf_bar = workflow.add_status(name='bar')
|
||||||
|
wf_baz = workflow.add_status(name='baz')
|
||||||
|
workflow.store()
|
||||||
|
|
||||||
|
formdef = FormDef()
|
||||||
|
formdef.name = 'Form title'
|
||||||
|
formdef.workflow = workflow
|
||||||
|
formdef.fields = []
|
||||||
|
formdef.store()
|
||||||
|
|
||||||
|
formdef.data_class().wipe()
|
||||||
|
|
||||||
|
formdata1 = formdef.data_class()()
|
||||||
|
formdata1.data = {}
|
||||||
|
formdata1.status = 'wf-%s' % wf_bar.id
|
||||||
|
formdata1.store()
|
||||||
|
|
||||||
|
formdata2 = formdef.data_class()()
|
||||||
|
formdata2.data = {}
|
||||||
|
formdata2.status = 'wf-%s' % wf_baz.id
|
||||||
|
formdata2.store()
|
||||||
|
|
||||||
|
app = login(get_app(pub))
|
||||||
|
|
||||||
|
for action in ('nothing', 'delete', 'reassign'):
|
||||||
|
# restore workflow & formdata
|
||||||
|
workflow.store()
|
||||||
|
formdata2.store()
|
||||||
|
|
||||||
|
resp = app.get('/backoffice/workflows/1/status/%s/' % wf_baz.id)
|
||||||
|
resp = resp.click('Delete')
|
||||||
|
resp = resp.form.submit('submit')
|
||||||
|
assert resp.location.endswith('/reassign')
|
||||||
|
resp = resp.follow()
|
||||||
|
|
||||||
|
if action == 'nothing':
|
||||||
|
resp.form['action'].value = 'Do nothing'
|
||||||
|
resp = resp.form.submit('submit')
|
||||||
|
resp = resp.follow()
|
||||||
|
assert formdef.data_class().get(formdata2.id).status == 'wf-%s' % wf_baz.id
|
||||||
|
elif action == 'remove':
|
||||||
|
resp.form['action'].value = 'Remove these forms'
|
||||||
|
resp = resp.form.submit('submit')
|
||||||
|
resp = resp.follow()
|
||||||
|
assert formdef.data_class().has_key(formdata1.id)
|
||||||
|
assert not formdef.data_class().has_key(formdata2.id)
|
||||||
|
elif action == 'reassign':
|
||||||
|
resp.form['action'].value = 'Change these forms status to "bar"'
|
||||||
|
resp = resp.form.submit('submit')
|
||||||
|
resp = resp.follow()
|
||||||
|
assert formdef.data_class().get(formdata2.id).status == 'wf-%s' % wf_bar.id
|
||||||
|
|
||||||
|
|
||||||
def test_workflows_delete(pub):
|
def test_workflows_delete(pub):
|
||||||
Workflow.wipe()
|
Workflow.wipe()
|
||||||
workflow = Workflow(name='foo')
|
workflow = Workflow(name='foo')
|
||||||
|
|
|
@ -739,7 +739,7 @@ class WorkflowStatusPage(Directory):
|
||||||
evo = Evolution()
|
evo = Evolution()
|
||||||
evo.time = time.localtime()
|
evo.time = time.localtime()
|
||||||
evo.status = new_status
|
evo.status = new_status
|
||||||
evo.comment = _('Administrator reassigned status')
|
evo.comment = str(_('Administrator reassigned status'))
|
||||||
if not item.evolution:
|
if not item.evolution:
|
||||||
item.evolution = []
|
item.evolution = []
|
||||||
item.evolution.append(evo)
|
item.evolution.append(evo)
|
||||||
|
|
Loading…
Reference in New Issue