workflows: make sure model filenames are unique (#14096)
This commit is contained in:
parent
0192a69306
commit
7e2af623ef
|
@ -211,6 +211,7 @@ def test_display_form_action():
|
|||
|
||||
def test_export_to_model_action():
|
||||
wf = Workflow(name='status')
|
||||
wf.store()
|
||||
st1 = wf.add_status('Status1', 'st1')
|
||||
|
||||
from quixote.http_request import Upload
|
||||
|
@ -247,6 +248,16 @@ def test_export_to_model_action():
|
|||
wf2 = assert_import_export_works(wf)
|
||||
assert wf2.possible_status[0].items[0].model_file.get_file().read() == file_content
|
||||
|
||||
wf2 = assert_import_export_works(wf, include_id=True)
|
||||
wf3 = assert_import_export_works(wf2, include_id=True)
|
||||
assert wf2.possible_status[0].items[0].model_file.filename == \
|
||||
wf3.possible_status[0].items[0].model_file.filename
|
||||
|
||||
wf3 = assert_import_export_works(wf2, include_id=False)
|
||||
assert wf2.possible_status[0].items[0].model_file.filename != \
|
||||
wf3.possible_status[0].items[0].model_file.filename
|
||||
|
||||
|
||||
def test_export_roles():
|
||||
wf = Workflow(name='roles')
|
||||
wf.roles = {'foo': 'Bar'}
|
||||
|
|
|
@ -19,6 +19,7 @@ import collections
|
|||
from StringIO import StringIO
|
||||
from xml.etree import ElementTree as ET
|
||||
import zipfile
|
||||
import random
|
||||
import subprocess
|
||||
import tempfile
|
||||
import shutil
|
||||
|
@ -458,7 +459,11 @@ class ExportToModel(WorkflowStatusItem):
|
|||
if elem.find('content') is not None:
|
||||
content = elem.find('content').text
|
||||
|
||||
ids = (self.parent.parent.id, self.parent.id, self.id)
|
||||
if self.parent.parent.id:
|
||||
ids = (self.parent.parent.id, self.parent.id, self.id)
|
||||
else:
|
||||
# hopefully this will be random enough.
|
||||
ids = ('i%i' % random.randint(0, 1000000), self.parent.id, self.id)
|
||||
filename = 'export_to_model-%s-%s-%s.upload' % ids
|
||||
|
||||
upload = Upload(base_filename, content_type)
|
||||
|
|
Loading…
Reference in New Issue