admin: use binary files for theme/global export/import (#36515)
This commit is contained in:
parent
1591530889
commit
7a446f5c88
|
@ -4213,8 +4213,8 @@ def test_settings_export_import(pub, studio):
|
|||
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()
|
||||
file_content = b'''PK\x03\x04\x14\x00\x00\x08\x00\x00\'l\x8eG^\xc62\x0c\'\x00'''
|
||||
upload.fp = BytesIO()
|
||||
upload.fp.write(file_content)
|
||||
upload.fp.seek(0)
|
||||
export_to.model_file = UploadedFile('models', 'export_to_model-1.upload', upload)
|
||||
|
|
|
@ -28,7 +28,7 @@ import shutil
|
|||
import xml.etree.ElementTree as ET
|
||||
|
||||
from django.utils.encoding import force_bytes
|
||||
from django.utils.six import StringIO
|
||||
from django.utils.six import BytesIO, StringIO
|
||||
|
||||
from quixote import get_publisher, get_request, get_response, redirect
|
||||
from quixote.directory import Directory
|
||||
|
@ -686,7 +686,7 @@ class SettingsDirectory(QommonSettingsDirectory):
|
|||
return redirect('themes')
|
||||
|
||||
parent_theme_directory = os.path.dirname(theme_directory)
|
||||
c = StringIO()
|
||||
c = BytesIO()
|
||||
z = zipfile.ZipFile(c, 'w')
|
||||
for base, dirnames, filenames in os.walk(theme_directory):
|
||||
basetheme = base[len(parent_theme_directory)+1:]
|
||||
|
@ -883,7 +883,7 @@ class SettingsDirectory(QommonSettingsDirectory):
|
|||
self.settings = settings
|
||||
|
||||
def export(self, job):
|
||||
c = StringIO()
|
||||
c = BytesIO()
|
||||
z = zipfile.ZipFile(c, 'w')
|
||||
for d in self.dirs:
|
||||
if d not in ('roles', 'categories', 'datasources', 'wscalls'):
|
||||
|
@ -900,19 +900,19 @@ class SettingsDirectory(QommonSettingsDirectory):
|
|||
node = formdef.export_to_xml(include_id=True)
|
||||
misc.indent_xml(node)
|
||||
z.writestr(os.path.join('formdefs_xml', str(formdef.id)),
|
||||
'<?xml version="1.0"?>\n' + ET.tostring(node))
|
||||
b'<?xml version="1.0"?>\n' + ET.tostring(node))
|
||||
if 'carddefs' in self.dirs:
|
||||
for formdef in CardDef.select():
|
||||
node = formdef.export_to_xml(include_id=True)
|
||||
misc.indent_xml(node)
|
||||
z.writestr(os.path.join('carddefs_xml', str(formdef.id)),
|
||||
'<?xml version="1.0"?>\n' + ET.tostring(node))
|
||||
b'<?xml version="1.0"?>\n' + ET.tostring(node))
|
||||
if 'workflows' in self.dirs:
|
||||
for workflow in Workflow.select():
|
||||
node = workflow.export_to_xml(include_id=True)
|
||||
misc.indent_xml(node)
|
||||
z.writestr(os.path.join('workflows_xml', str(workflow.id)),
|
||||
'<?xml version="1.0"?>\n' + ET.tostring(node))
|
||||
b'<?xml version="1.0"?>\n' + ET.tostring(node))
|
||||
|
||||
if self.settings:
|
||||
z.write(os.path.join(self.app_dir, 'config.pck'), 'config.pck')
|
||||
|
|
|
@ -213,7 +213,7 @@ class WcsPublisher(StubWcsPublisher):
|
|||
del self.cfg['sp']
|
||||
self.write_cfg()
|
||||
continue
|
||||
open(path, 'w').write(data)
|
||||
open(path, 'wb').write(data)
|
||||
if os.path.split(f)[0] in results:
|
||||
results[os.path.split(f)[0]] += 1
|
||||
|
||||
|
|
Loading…
Reference in New Issue