settings: export models with workflows (#27942)

This commit is contained in:
Thomas NOËL 2018-11-13 14:48:23 +01:00
parent c6e536e02e
commit 2c36a05d40
2 changed files with 21 additions and 1 deletions

View File

@ -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

View File

@ -849,6 +849,8 @@ class SettingsDirectory(QommonSettingsDirectory):
'datasources', 'wscalls'):
if form.get_widget(w) and form.get_widget(w).parse():
dirs.append(w)
if 'workflows' in dirs:
dirs.append('models')
if not dirs and not form.get_widget('settings').parse():
return redirect('.')