From ba5eb6f97ee6725b7478ae85955acb23cac51a4d Mon Sep 17 00:00:00 2001 From: Thomas NOEL Date: Tue, 13 Nov 2018 14:48:23 +0100 Subject: [PATCH] settings: export models with workflows (#27942) --- tests/test_admin_pages.py | 20 +++++++++++++++++++- wcs/admin/settings.py | 2 ++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/tests/test_admin_pages.py b/tests/test_admin_pages.py index dbe9bd9b..2c2440d3 100644 --- a/tests/test_admin_pages.py +++ b/tests/test_admin_pages.py @@ -22,7 +22,10 @@ from webtest import Upload import mock from quixote import cleanup, get_publisher +from quixote.http_request import Upload as QuixoteUpload + from wcs.qommon import errors, sessions +from wcs.qommon.form import UploadedFile from qommon.ident.password_accounts import PasswordAccount from wcs.qommon.http_request import HTTPRequest from wcs.qommon.template import get_current_theme @@ -3736,12 +3739,25 @@ def test_settings_export_import(pub): formdef = FormDef() formdef.name = 'foo' formdef.store() - Workflow(name='bar').store() Category(name='baz').store() Role(name='qux').store() NamedDataSource(name='quux').store() NamedWsCall(name='corge').store() + wf = Workflow(name='bar') + st1 = wf.add_status('Status1', 'st1') + export_to = ExportToModel() + export_to.label = 'test' + upload = QuixoteUpload('/foo/bar', content_type='application/vnd.oasis.opendocument.text') + file_content = '''PK\x03\x04\x14\x00\x00\x08\x00\x00\'l\x8eG^\xc62\x0c\'\x00''' + upload.fp = StringIO.StringIO() + upload.fp.write(file_content) + upload.fp.seek(0) + export_to.model_file = UploadedFile('models', 'export_to_model-1.upload', upload) + st1.items.append(export_to) + export_to.parent = st1 + wf.store() + resp = app.get('/backoffice/settings/export') resp = resp.form.submit('submit') zip_content = StringIO.StringIO(resp.body) @@ -3749,6 +3765,7 @@ def test_settings_export_import(pub): filelist = zipf.namelist() assert 'formdefs/1' in filelist assert 'workflows/1' in filelist + assert 'models/export_to_model-1.upload' in filelist assert 'roles/1' in filelist assert 'categories/1' in filelist assert 'datasources/1' in filelist @@ -3783,6 +3800,7 @@ def test_settings_export_import(pub): filelist = zipf.namelist() assert 'formdefs/1' in filelist assert 'workflows/1' in filelist + assert 'models/export_to_model-1.upload' in filelist assert 'roles/1' not in filelist assert 'categories/1' in filelist assert 'datasources/1' in filelist diff --git a/wcs/admin/settings.py b/wcs/admin/settings.py index 26bd536c..d2b84489 100644 --- a/wcs/admin/settings.py +++ b/wcs/admin/settings.py @@ -849,6 +849,8 @@ class SettingsDirectory(QommonSettingsDirectory): 'datasources', 'wscalls'): if form.get_widget(w) and form.get_widget(w).parse(): dirs.append(w) + if w == 'workflows': + dirs.append('models') if not dirs and not form.get_widget('settings').parse(): return redirect('.') -- 2.19.1