0001-misc-include-object-url-in-XML-exports-51899.patch
tests/admin_pages/test_form.py | ||
---|---|---|
1018 | 1018 | |
1019 | 1019 |
resp = resp.click(href='export') |
1020 | 1020 |
xml_export = resp.text |
1021 |
assert ET.fromstring(xml_export).attrib['url'] == 'http://example.net/backoffice/forms/1/' |
|
1021 | 1022 | |
1022 | 1023 |
fd = io.StringIO(xml_export) |
1023 | 1024 |
formdef2 = FormDef.import_from_xml(fd) |
tests/admin_pages/test_workflow.py | ||
---|---|---|
350 | 350 |
app = login(get_app(pub)) |
351 | 351 |
resp = app.get('/backoffice/workflows/1/') |
352 | 352 |
resp = resp.click('Export') |
353 |
assert resp.content_type == 'application/x-wcs-form'
|
|
353 |
assert resp.content_type == 'application/x-wcs-workflow'
|
|
354 | 354 |
wf_export = resp.body |
355 | 355 | |
356 | 356 |
resp = app.get('/backoffice/workflows/') |
... | ... | |
381 | 381 |
app = login(get_app(pub)) |
382 | 382 |
resp = app.get('/backoffice/workflows/1/') |
383 | 383 |
resp = resp.click('Export') |
384 |
assert resp.content_type == 'application/x-wcs-form'
|
|
384 |
assert resp.content_type == 'application/x-wcs-workflow'
|
|
385 | 385 |
wf_export = resp.body |
386 | 386 | |
387 | 387 |
resp = app.get('/backoffice/workflows/') |
... | ... | |
421 | 421 |
app = login(get_app(pub)) |
422 | 422 |
resp = app.get('/backoffice/workflows/1/') |
423 | 423 |
resp = resp.click('Export') |
424 |
assert resp.content_type == 'application/x-wcs-form'
|
|
424 |
assert resp.content_type == 'application/x-wcs-workflow'
|
|
425 | 425 |
wf_export = resp.body |
426 | 426 | |
427 | 427 |
resp = app.get('/backoffice/workflows/') |
wcs/admin/blocks.py | ||
---|---|---|
14 | 14 |
# You should have received a copy of the GNU General Public License |
15 | 15 |
# along with this program; if not, see <http://www.gnu.org/licenses/>. |
16 | 16 | |
17 |
import xml.etree.ElementTree as ET |
|
18 | ||
19 | 17 |
from quixote import get_publisher, get_response, get_session, redirect |
20 | 18 |
from quixote.directory import Directory |
21 | 19 |
from quixote.html import TemplateIO, htmltext |
... | ... | |
128 | 126 |
return redirect('..') |
129 | 127 | |
130 | 128 |
def export(self): |
131 |
x = self.objectdef.export_to_xml(include_id=True) |
|
132 |
misc.indent_xml(x) |
|
133 |
response = get_response() |
|
134 |
response.set_content_type('application/x-wcs-form') |
|
135 |
response.set_header('content-disposition', 'attachment; filename=block-%s.wcs' % self.objectdef.slug) |
|
136 |
return '<?xml version="1.0"?>\n' + ET.tostring(x).decode('utf-8') |
|
129 |
return misc.xml_response( |
|
130 |
self.objectdef, |
|
131 |
filename='block-%s.wcs' % self.objectdef.slug, |
|
132 |
content_type='application/x-wcs-form', |
|
133 |
) |
|
137 | 134 | |
138 | 135 |
def settings(self): |
139 | 136 |
get_response().breadcrumb.append(('settings', _('Settings'))) |
wcs/admin/data_sources.py | ||
---|---|---|
14 | 14 |
# You should have received a copy of the GNU General Public License |
15 | 15 |
# along with this program; if not, see <http://www.gnu.org/licenses/>. |
16 | 16 | |
17 |
import xml.etree.ElementTree as ET |
|
18 | ||
19 | 17 |
from quixote import get_publisher, redirect |
20 | 18 |
from quixote.directory import Directory |
21 | 19 |
from quixote.html import TemplateIO, htmltext |
... | ... | |
31 | 29 |
has_chrono, |
32 | 30 |
) |
33 | 31 |
from wcs.formdef import get_formdefs_of_all_kinds |
34 |
from wcs.qommon import _, errors, force_str, misc, template
|
|
32 |
from wcs.qommon import _, errors, misc, template |
|
35 | 33 |
from wcs.qommon.backoffice.menu import html_top |
36 | 34 |
from wcs.qommon.form import ( |
37 | 35 |
CheckboxWidget, |
... | ... | |
371 | 369 |
return redirect('..') |
372 | 370 | |
373 | 371 |
def export(self): |
374 |
x = self.datasource.export_to_xml(include_id=True) |
|
375 |
misc.indent_xml(x) |
|
376 |
response = get_response() |
|
377 |
response.set_content_type('application/x-wcs-datasource') |
|
378 |
response.set_header( |
|
379 |
'content-disposition', 'attachment; filename=datasource-%s.wcs' % self.datasource.slug |
|
372 |
return misc.xml_response( |
|
373 |
self.datasource, |
|
374 |
filename='datasource-%s.wcs' % self.datasource.slug, |
|
375 |
content_type='application/x-wcs-datasource', |
|
380 | 376 |
) |
381 |
return '<?xml version="1.0"?>\n' + force_str(ET.tostring(x)) |
|
382 | 377 | |
383 | 378 | |
384 | 379 |
class NamedDataSourcesDirectory(Directory): |
wcs/admin/forms.py | ||
---|---|---|
1466 | 1466 |
return r.getvalue() |
1467 | 1467 | |
1468 | 1468 |
def export(self): |
1469 |
x = self.formdef.export_to_xml(include_id=True) |
|
1470 |
misc.indent_xml(x) |
|
1471 |
response = get_response() |
|
1472 |
response.set_content_type('application/x-wcs-form') |
|
1473 |
response.set_header( |
|
1474 |
'content-disposition', |
|
1475 |
'attachment; filename=%s-%s.wcs' % (self.formdef_export_prefix, self.formdef.url_name), |
|
1469 |
return misc.xml_response( |
|
1470 |
self.formdef, |
|
1471 |
filename='%s-%s.wcs' % (self.formdef_export_prefix, self.formdef.url_name), |
|
1472 |
content_type='application/x-wcs-form', |
|
1476 | 1473 |
) |
1477 |
return '<?xml version="1.0"?>\n' + force_str(ET.tostring(x)) |
|
1478 | 1474 | |
1479 | 1475 |
def archive(self): |
1480 | 1476 |
if get_publisher().is_using_postgresql(): |
wcs/admin/mail_templates.py | ||
---|---|---|
14 | 14 |
# You should have received a copy of the GNU General Public License |
15 | 15 |
# along with this program; if not, see <http://www.gnu.org/licenses/>. |
16 | 16 | |
17 |
import xml.etree.ElementTree as ET |
|
18 | ||
19 | 17 |
from quixote import get_publisher, get_response, redirect |
20 | 18 |
from quixote.directory import Directory |
21 | 19 |
from quixote.html import TemplateIO, htmltext |
22 | 20 | |
23 | 21 |
from wcs.mail_templates import MailTemplate |
24 |
from wcs.qommon import _, errors, force_str, misc, template
|
|
22 |
from wcs.qommon import _, errors, misc, template |
|
25 | 23 |
from wcs.qommon.backoffice.menu import html_top |
26 | 24 |
from wcs.qommon.form import ( |
27 | 25 |
ComputedExpressionWidget, |
... | ... | |
279 | 277 |
return redirect('..') |
280 | 278 | |
281 | 279 |
def export(self): |
282 |
x = self.mail_template.export_to_xml(include_id=True) |
|
283 |
misc.indent_xml(x) |
|
284 |
response = get_response() |
|
285 |
response.set_content_type('application/x-wcs-mail-template') |
|
286 |
response.set_header( |
|
287 |
'content-disposition', 'attachment; filename=mail-template-%s.wcs' % self.mail_template.slug |
|
280 |
return misc.xml_response( |
|
281 |
self.mail_template, |
|
282 |
filename='mail-template-%s.wcs' % self.mail_template.slug, |
|
283 |
content_type='application/x-wcs-mail-template', |
|
288 | 284 |
) |
289 |
return '<?xml version="1.0"?>\n' + force_str(ET.tostring(x)) |
wcs/admin/workflows.py | ||
---|---|---|
1696 | 1696 |
) |
1697 | 1697 | |
1698 | 1698 |
def export(self): |
1699 |
x = self.workflow.export_to_xml(include_id=True) |
|
1700 |
misc.indent_xml(x) |
|
1701 |
response = get_response() |
|
1702 |
response.set_content_type('application/x-wcs-form') |
|
1703 |
response.set_header( |
|
1704 |
'content-disposition', 'attachment; filename=workflow-%s.wcs' % misc.simplify(self.workflow.name) |
|
1699 |
return misc.xml_response( |
|
1700 |
self.workflow, |
|
1701 |
filename='workflow-%s.wcs' % misc.simplify(self.workflow.name), |
|
1702 |
content_type='application/x-wcs-workflow', |
|
1705 | 1703 |
) |
1706 |
return '<?xml version="1.0"?>\n' + force_str(ET.tostring(x)) |
|
1707 | 1704 | |
1708 | 1705 |
def get_new_status_form(self): |
1709 | 1706 |
r = TemplateIO(html=True) |
wcs/admin/wscalls.py | ||
---|---|---|
14 | 14 |
# You should have received a copy of the GNU General Public License |
15 | 15 |
# along with this program; if not, see <http://www.gnu.org/licenses/>. |
16 | 16 | |
17 |
import xml.etree.ElementTree as ET |
|
18 | ||
19 | 17 |
from quixote import get_publisher, get_response, get_session, redirect |
20 | 18 |
from quixote.directory import Directory |
21 | 19 |
from quixote.html import TemplateIO, htmltext |
22 | 20 | |
23 | 21 |
from wcs.admin import utils |
24 | 22 |
from wcs.backoffice.snapshots import SnapshotsDirectory |
25 |
from wcs.qommon import _, errors, force_str, misc, template
|
|
23 |
from wcs.qommon import _, errors, misc, template |
|
26 | 24 |
from wcs.qommon.backoffice.menu import html_top |
27 | 25 |
from wcs.qommon.form import CheckboxWidget, FileWidget, Form, HtmlWidget, StringWidget, TextWidget |
28 | 26 |
from wcs.wscalls import NamedWsCall, WsCallRequestWidget |
... | ... | |
177 | 175 |
return redirect('..') |
178 | 176 | |
179 | 177 |
def export(self): |
180 |
x = self.wscall.export_to_xml(include_id=True) |
|
181 |
misc.indent_xml(x) |
|
182 |
response = get_response() |
|
183 |
response.set_content_type('application/x-wcs-wscall') |
|
184 |
response.set_header('content-disposition', 'attachment; filename=wscall-%s.wcs' % self.wscall.slug) |
|
185 |
return '<?xml version="1.0"?>\n' + force_str(ET.tostring(x)) |
|
178 |
return misc.xml_response( |
|
179 |
self.wscall, filename='wscall-%s.wcs' % self.wscall.slug, content_type='application/x-wcs-wscall' |
|
180 |
) |
|
186 | 181 | |
187 | 182 | |
188 | 183 |
class NamedWsCallsDirectory(Directory): |
wcs/qommon/misc.py | ||
---|---|---|
28 | 28 |
import time |
29 | 29 |
import unicodedata |
30 | 30 |
import urllib.parse |
31 |
import xml.etree.ElementTree as ET |
|
31 | 32 | |
32 | 33 |
import requests |
33 | 34 |
from requests.adapters import HTTPAdapter |
... | ... | |
996 | 997 |
options = [({}, '---', '')] |
997 | 998 |
options += [(doc_type, doc_type['label'], key) for key, doc_type in document_types.items()] |
998 | 999 |
return options |
1000 | ||
1001 | ||
1002 |
def xml_response(obj, filename, content_type='text/xml'): |
|
1003 |
etree = obj.export_to_xml(include_id=True) |
|
1004 |
if hasattr(obj, 'get_admin_url'): |
|
1005 |
etree.attrib['url'] = obj.get_admin_url() |
|
1006 |
indent_xml(etree) |
|
1007 |
response = get_response() |
|
1008 |
response.set_content_type(content_type) |
|
1009 |
response.set_header('content-disposition', 'attachment; filename=%s' % filename) |
|
1010 |
return '<?xml version="1.0"?>\n' + ET.tostring(etree).decode('utf-8') |
|
999 |
- |