diff --git a/CHANGES.rst b/CHANGES.rst index 177d876e..8a086a18 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -5,6 +5,15 @@ Changelog 1.13 (unreleased) ----------------- +- Fix styling of ``export_content`` page in Plone 6.1. + The checkbox inputs were displayed in block instead of inline with the label. + [maurits] + +- Make it possible to switch off changing data for migration. + Previous, you could uncheck this checkbox in ``export_content``, but this was ignored. + This fixes `issue 247 `_. + [maurits] + - Load code for exporting/importing comments conditionally. ``plone.app.discussion`` is optional since Plone 6.1. [maurits] diff --git a/requirements.txt b/requirements.txt index 3f1fb9bb..2f75cfe5 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ # For Buildout related packages, it is easiest to keep them at the same version for all environments. # Keep these in sync with base.cfg please: -zc.buildout==3.0.1 +zc.buildout==3.3 # setuptools 67 is too strict with versions setuptools<67 diff --git a/src/collective/exportimport/export_content.py b/src/collective/exportimport/export_content.py index f5501feb..53ab6825 100644 --- a/src/collective/exportimport/export_content.py +++ b/src/collective/exportimport/export_content.py @@ -110,14 +110,24 @@ def __call__( depth=-1, include_blobs=1, download_to_server=False, - migration=True, + migration=False, include_revisions=False, write_errors=False, ): self.portal_type = portal_type or [] if isinstance(self.portal_type, str): self.portal_type = [self.portal_type] - self.migration = migration + + # Should we adapt the data for migration? + # We had migration=True by default at first. Problem is that when you + # uncheck the migration box in the form, it does not end up in the + # request, so migration would still be True. See + # https://github.com/collective/collective.exportimport/issues/247 + if self.request.method == "GET": + # By default we want this, so on initial page load we make it true. + self.migration = True + else: + self.migration = migration self.path = path or "/".join(self.context.getPhysicalPath()) self.depth = int(depth) diff --git a/src/collective/exportimport/templates/export_content.pt b/src/collective/exportimport/templates/export_content.pt index 2b61501e..a7a9b19c 100644 --- a/src/collective/exportimport/templates/export_content.pt +++ b/src/collective/exportimport/templates/export_content.pt @@ -5,6 +5,9 @@ i18n:domain="collective.exportimport" metal:use-macro="context/main_template/macros/master"> +
diff --git a/src/collective/exportimport/tests/test_export.py b/src/collective/exportimport/tests/test_export.py index b4daceb7..95c82479 100644 --- a/src/collective/exportimport/tests/test_export.py +++ b/src/collective/exportimport/tests/test_export.py @@ -100,7 +100,7 @@ def test_export_content_page(self): with self.assertRaises(LookupError): browser.getControl(name="portal_type") - def test_export_content_document(self): + def test_export_content_document_with_migration(self): # First create some content. app = self.layer["app"] portal = self.layer["portal"] @@ -112,6 +112,7 @@ def test_export_content_document(self): # Now export Documents. browser = self.open_page("@@export_content") + self.assertTrue(browser.getControl(name="migration:boolean").value) portal_type = browser.getControl(name="portal_type") self.assertEqual(portal_type.value, []) self.assertIn("Document", portal_type.options) @@ -137,6 +138,54 @@ def test_export_content_document(self): self.assertEqual(info["@type"], "Document") self.assertEqual(info["title"], doc.Title()) + # By default, we adapt the data for migration. This means some data + # from the standard REST API call should not be there. + keys = sorted(info.keys()) + self.assertNotIn(u"@components", keys) + self.assertNotIn(u"next_item", keys) + + def test_export_content_document_without_migration(self): + # First create some content. + app = self.layer["app"] + portal = self.layer["portal"] + login(app, SITE_OWNER_NAME) + doc = api.content.create( + container=portal, type="Document", id="doc1", title="Document 1" + ) + transaction.commit() + + # Now export Documents. + browser = self.open_page("@@export_content") + # Here is the difference with the previous test method: + # do not adapt the data for migration. + browser.getControl(name="migration:boolean").value = False + portal_type = browser.getControl(name="portal_type") + portal_type.value = ["Document"] + try: + # Plone 5.2 + browser.getForm(action="@@export_content").submit(name="submit") + except LookupError: + # Plone 5.1 and lower + browser.getForm(index=1).submit() + contents = browser.contents + if not browser.contents: + contents = DATA[-1] + + # We should have gotten json. + data = json.loads(contents) + self.assertEqual(len(data), 1) + + # Some important keys should still be there. + info = data[0] + self.assertEqual(info["@id"], portal.absolute_url() + "/doc1") + self.assertEqual(info["@type"], "Document") + self.assertEqual(info["title"], doc.Title()) + + # Now all the standard REST API keys should be there. + keys = sorted(info.keys()) + self.assertIn(u"@components", keys) + self.assertIn(u"next_item", keys) + def test_export_collection(self): # First create some content. app = self.layer["app"] diff --git a/tox.ini b/tox.ini index 9cabc12a..3a6335a8 100644 --- a/tox.ini +++ b/tox.ini @@ -5,7 +5,7 @@ envlist = plone50-py27 plone51-py27 plone52-py{27,36,37,38} - plone60-py{38,39} + plone60-py{39,310,311} [testenv] # We do not install with pip, but with buildout: