From 7901040bb4d2d019783686bd26673ad0676a3bdc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Wed, 17 Feb 2016 20:02:48 +0100 Subject: [PATCH] admin: don't lose drafts when assigning a new workflow to a formdef (#10017) --- tests/test_admin_pages.py | 16 +++++++++++----- wcs/admin/forms.py | 2 +- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/tests/test_admin_pages.py b/tests/test_admin_pages.py index 95255de..0847a37 100644 --- a/tests/test_admin_pages.py +++ b/tests/test_admin_pages.py @@ -415,9 +415,13 @@ def test_form_workflow_remapping(pub): data_class = formdef.data_class() data_class.wipe() - formdata = data_class() - formdata.status = 'wf-new' - formdata.store() + formdata1 = data_class() + formdata1.status = 'wf-new' + formdata1.store() + + formdata2 = data_class() + formdata2.status = 'draft' + formdata2.store() Workflow.wipe() workflow = Workflow(name='Workflow One') @@ -438,9 +442,11 @@ def test_form_workflow_remapping(pub): assert resp.forms[0]['mapping-%s' % status.id] # there's only one possible new status assert len(resp.forms[0]['mapping-just_submitted'].options) == 1 - assert data_class.get(1).status == 'wf-new' + assert data_class.get(formdata1.id).status == 'wf-new' + assert data_class.get(formdata2.id).status == 'draft' resp = resp.forms[0].submit() - assert data_class.get(1).status == 'wf-finished' + assert data_class.get(formdata1.id).status == 'wf-finished' + assert data_class.get(formdata2.id).status == 'draft' def test_form_workflow_role(pub): create_superuser(pub) diff --git a/wcs/admin/forms.py b/wcs/admin/forms.py index f247742..9019f49 100644 --- a/wcs/admin/forms.py +++ b/wcs/admin/forms.py @@ -728,7 +728,7 @@ class FormDefPage(Directory): return redirect('.') def workflow_status_remapping_submit(self, form): - status_mapping = {'wf-draft': 'wf-draft'} + status_mapping = {'wf-draft': 'draft', 'draft': 'draft'} for status in self.formdef.workflow.possible_status: status_mapping['wf-%s' % status.id] = 'wf-%s' % \ form.get_widget('mapping-%s' % status.id).parse() -- 2.7.0