From 66f2f0d6a69a05ace5c7112e3b7cfdbb3205266b Mon Sep 17 00:00:00 2001 From: mauritsvanrees Date: Wed, 4 Sep 2024 21:44:39 +0200 Subject: [PATCH] [fc] Repository: plone.app.discussion Branch: refs/heads/main Date: 2024-09-02T17:38:21+02:00 Author: Maurits van Rees (mauritsvanrees) Commit: https://github.com/plone/plone.app.discussion/commit/feb6196979e0801621a91dd1cc0bc471098c2026 When installing plone.app.discussion enable comments globally. In 6.1 you have to explicitly install the add-on in the Add-ons control panel. If you do that, then you obviously want discussions to be enabled globally. I think this also helps for the Volto case, where a Discussion control panel is missing, so in Plone 6.0 you cannot even properly enable comments. Files changed: M news/211.breaking M plone/app/discussion/interfaces.py M plone/app/discussion/testing.py M plone/app/discussion/tests/test_controlpanel.py Repository: plone.app.discussion Branch: refs/heads/main Date: 2024-09-02T17:49:53+02:00 Author: Maurits van Rees (mauritsvanrees) Commit: https://github.com/plone/plone.app.discussion/commit/5129fb914d13a300e62efd6c99d46b4b925ef470 Remove test code for ancient ATContentTypes Topics. This was only used in the `collection-integration-test.txt`, but this is actually currently not being tested. Files changed: M plone/app/discussion/testing.py M plone/app/discussion/tests/collection-integration-test.txt Repository: plone.app.discussion Branch: refs/heads/main Date: 2024-09-04T21:44:39+02:00 Author: Maurits van Rees (mauritsvanrees) Commit: https://github.com/plone/plone.app.discussion/commit/e08c5d87efe4fbb740264dafac62a45ddf05007c Merge pull request #244 from plone/maurits-globally-enable-comments Globally enable comments on install Files changed: M news/211.breaking M plone/app/discussion/interfaces.py M plone/app/discussion/testing.py M plone/app/discussion/tests/collection-integration-test.txt M plone/app/discussion/tests/test_controlpanel.py --- last_commit.txt | 67 +++++++++++++++++++++++++++++++++++++------------ 1 file changed, 51 insertions(+), 16 deletions(-) diff --git a/last_commit.txt b/last_commit.txt index 4ad61481c5..81829ef14c 100644 --- a/last_commit.txt +++ b/last_commit.txt @@ -1,26 +1,61 @@ -Repository: plone.restapi +Repository: plone.app.discussion Branch: refs/heads/main -Date: 2024-09-04T21:43:29+02:00 +Date: 2024-09-02T17:38:21+02:00 Author: Maurits van Rees (mauritsvanrees) -Commit: https://github.com/plone/plone.restapi/commit/7b1f0f4c4bff5cba26cf7925e306cfa12fc2c3b3 +Commit: https://github.com/plone/plone.app.discussion/commit/feb6196979e0801621a91dd1cc0bc471098c2026 -Explicitly globally disable comments in the tests that need it. (#1805) +When installing plone.app.discussion enable comments globally. -In Plone 6.1, when you actively activate plone.app.discussion, we may globally enable comments by default. -This is when https://github.com/plone/plone.app.discussion/pull/244 gets merged. - -We already had eight or so tests that explicitly globally enable comments. -Now we explicitly globally disable them in two others. -Then the tests work in Plone 6.0 and 6.1. - -See two test failures here for the plone.app.discussion PR: -https://jenkins.plone.org/job/pull-request-6.1-3.10/311/ +In 6.1 you have to explicitly install the add-on in the Add-ons control panel. +If you do that, then you obviously want discussions to be enabled globally. +I think this also helps for the Volto case, where a Discussion control panel is missing, so in Plone 6.0 you cannot even properly enable comments. Files changed: -A news/244.tests -M src/plone/restapi/tests/test_dxcontent_serializer.py +M news/211.breaking +M plone/app/discussion/interfaces.py +M plone/app/discussion/testing.py +M plone/app/discussion/tests/test_controlpanel.py -b'diff --git a/news/244.tests b/news/244.tests\nnew file mode 100644\nindex 000000000..0ee4acc1f\n--- /dev/null\n+++ b/news/244.tests\n@@ -0,0 +1,2 @@\n+Explicitly globally disable comments in the tests that need it.\n+[maurits]\n\\ No newline at end of file\ndiff --git a/src/plone/restapi/tests/test_dxcontent_serializer.py b/src/plone/restapi/tests/test_dxcontent_serializer.py\nindex 789cf865f..6fd514956 100644\n--- a/src/plone/restapi/tests/test_dxcontent_serializer.py\n+++ b/src/plone/restapi/tests/test_dxcontent_serializer.py\n@@ -527,6 +527,9 @@ def test_allow_discussion_by_default(self):\n self.assertEqual(False, obj["allow_discussion"])\n \n def test_allow_discussion_obj_instance_allows_but_not_global_enabled(self):\n+ registry = queryUtility(IRegistry)\n+ settings = registry.forInterface(IDiscussionSettings, check=False)\n+ settings.globally_enabled = False\n self.portal.invokeFactory("Document", id="doc2")\n self.portal.doc2.allow_discussion = True\n serializer = getMultiAdapter((self.portal.doc2, self.request), ISerializeToJson)\n@@ -536,6 +539,9 @@ def test_allow_discussion_obj_instance_allows_but_not_global_enabled(self):\n self.assertEqual(False, obj["allow_discussion"])\n \n def test_allow_discussion_fti_allows_not_global_enabled(self):\n+ registry = queryUtility(IRegistry)\n+ settings = registry.forInterface(IDiscussionSettings, check=False)\n+ settings.globally_enabled = False\n self.portal.invokeFactory("Document", id="doc2")\n portal_types = getToolByName(self.portal, "portal_types")\n document_fti = getattr(portal_types, self.portal.doc2.portal_type)\n' +b'diff --git a/news/211.breaking b/news/211.breaking\nindex f4cad3c5..62173580 100644\n--- a/news/211.breaking\n+++ b/news/211.breaking\n@@ -1,4 +1,5 @@\n Move this package in the space of Plone Core add-ons.\n It now depends on Products.CMFPlone and is no longer installed by default.\n It is still available in the default Plone distribution, but can be omitted in customizations.\n-[jensens]\n\\ No newline at end of file\n+Installing this in the Add-ons control panel will enable comments globally.\n+[jensens]\ndiff --git a/plone/app/discussion/interfaces.py b/plone/app/discussion/interfaces.py\nindex 5fca1385..eefa9c7d 100644\n--- a/plone/app/discussion/interfaces.py\n+++ b/plone/app/discussion/interfaces.py\n@@ -216,7 +216,7 @@ class IDiscussionSettings(Interface):\n "objects before users will be able to post comments.",\n ),\n required=False,\n- default=False,\n+ default=True,\n )\n \n anonymous_comments = schema.Bool(\ndiff --git a/plone/app/discussion/testing.py b/plone/app/discussion/testing.py\nindex 48a74392..18a396e3 100644\n--- a/plone/app/discussion/testing.py\n+++ b/plone/app/discussion/testing.py\n@@ -1,5 +1,4 @@\n from plone.app.contenttypes.testing import PLONE_APP_CONTENTTYPES_FIXTURE\n-from plone.app.discussion.interfaces import IDiscussionSettings\n from plone.app.robotframework.testing import REMOTE_LIBRARY_ROBOT_TESTING\n from plone.app.testing import applyProfile\n from plone.app.testing import FunctionalTesting\n@@ -8,9 +7,7 @@\n from plone.app.testing import setRoles\n from plone.app.testing import TEST_USER_ID\n from plone.app.testing import TEST_USER_PASSWORD\n-from plone.registry.interfaces import IRegistry\n from Products.CMFCore.utils import getToolByName\n-from zope.component import queryUtility\n \n \n try:\n@@ -105,12 +102,6 @@ class PloneAppDiscussionRobot(PloneAppDiscussion):\n REMOTE_LIBRARY_ROBOT_TESTING,\n )\n \n- def setUpPloneSite(self, portal):\n- applyProfile(portal, "plone.app.discussion:default")\n- registry = queryUtility(IRegistry)\n- settings = registry.forInterface(IDiscussionSettings)\n- settings.globally_enabled = True\n-\n \n PLONE_APP_DISCUSSION_ROBOT_FIXTURE = PloneAppDiscussionRobot()\n PLONE_APP_DISCUSSION_FIXTURE = PloneAppDiscussion()\ndiff --git a/plone/app/discussion/tests/test_controlpanel.py b/plone/app/discussion/tests/test_controlpanel.py\nindex 25bb6a14..e2271dbe 100644\n--- a/plone/app/discussion/tests/test_controlpanel.py\n+++ b/plone/app/discussion/tests/test_controlpanel.py\n@@ -49,7 +49,7 @@ def test_globally_enabled(self):\n "plone.app.discussion.interfaces."\n + "IDiscussionSettings.globally_enabled"\n ],\n- False,\n+ True,\n )\n \n def test_anonymous_comments(self):\n' + +Repository: plone.app.discussion + + +Branch: refs/heads/main +Date: 2024-09-02T17:49:53+02:00 +Author: Maurits van Rees (mauritsvanrees) +Commit: https://github.com/plone/plone.app.discussion/commit/5129fb914d13a300e62efd6c99d46b4b925ef470 + +Remove test code for ancient ATContentTypes Topics. + +This was only used in the `collection-integration-test.txt`, but this is actually currently not being tested. + +Files changed: +M plone/app/discussion/testing.py +M plone/app/discussion/tests/collection-integration-test.txt + +b'diff --git a/plone/app/discussion/testing.py b/plone/app/discussion/testing.py\nindex 18a396e3..83dafbb4 100644\n--- a/plone/app/discussion/testing.py\n+++ b/plone/app/discussion/testing.py\n@@ -10,14 +10,6 @@\n from Products.CMFCore.utils import getToolByName\n \n \n-try:\n- import plone.app.collection # noqa\n-\n- COLLECTION_TYPE = "Collection"\n-except ImportError:\n- COLLECTION_TYPE = "Topic"\n-\n-\n class PloneAppDiscussion(PloneSandboxLayer):\n defaultBases = (PLONE_APP_CONTENTTYPES_FIXTURE,)\n \ndiff --git a/plone/app/discussion/tests/collection-integration-test.txt b/plone/app/discussion/tests/collection-integration-test.txt\nindex c8814d43..b02c176b 100644\n--- a/plone/app/discussion/tests/collection-integration-test.txt\n+++ b/plone/app/discussion/tests/collection-integration-test.txt\n@@ -2,6 +2,8 @@ XXX: This functional test part has been removed due to the removal of\n ATContentTypes from PLONE_FIXTURE. We have to rewrite this test as a robot\n test because the dexterity collections do not work without js.\n \n+XXX To put this more plainly: this file is currently NOT tested.\n+\n \n List comments in a collection\n -----------------------------\n@@ -12,33 +14,24 @@ Create a collection.\n >>> from plone.app.testing import TEST_USER_NAME\n >>> setRoles(portal, \'manager\', [\'Manager\'])\n >>> browser.open(portal.absolute_url())\n- >>> from plone.app.discussion.testing import COLLECTION_TYPE\n- >>> browser.getLink(url=\'++add++\' + COLLECTION_TYPE).click()\n+ >>> browser.getLink(url=\'++add++Collection\').click()\n >>> open(\'/tmp/testbrowser.html\', \'w\').write(browser.contents)\n >>> browser.getControl(\'form.widgets.IDublinCore.title\').value = \'Foo Comment Collection\'\n >>> browser.getControl(\'Save\').click()\n >>> print(browser.contents)\n <...Changes saved...\n- >>> topic_url = browser.url\n+ >>> collection_url = browser.url\n \n Set the collection criteria.\n \n- >>> browser.open(topic_url + "/edit")\n+ >>> browser.open(collection_url + "/edit")\n \n- >>> if COLLECTION_TYPE == "Collection":\n- ... browser.getControl(name="addindex").value = [\'portal_type\']\n- ... browser.getControl(name="form.button.addcriteria").click()\n- ... browser.getControl(name="addoperator").value = [\'plone.app.querystring.operation.selection.any\']\n- ... browser.getControl(name="form.button.addcriteria").click()\n- ... browser.getControl(name="query.v:records:list").value = ["Discussion Item"]\n- ... browser.getControl(name="form.button.save").click()\n- ... else:\n- ... browser.getLink(\'Criteria\').click()\n- ... browser.getControl(\'Item Type\', index=0).selected = True\n- ... browser.getControl(\'Select content types\').selected = True\n- ... browser.getControl(\'Add criteria\').click()\n- ... browser.getControl(\'Comment\').selected = True\n- ... browser.getControl(\'Save\', index=0).click()\n+ >>> browser.getControl(name="addindex").value = [\'portal_type\']\n+ ... browser.getControl(name="form.button.addcriteria").click()\n+ ... browser.getControl(name="addoperator").value = [\'plone.app.querystring.operation.selection.any\']\n+ ... browser.getControl(name="form.button.addcriteria").click()\n+ ... browser.getControl(name="query.v:records:list").value = ["Discussion Item"]\n+ ... browser.getControl(name="form.button.save").click()\n >>> print(browser.contents)\n <...Changes saved...\n \n@@ -71,7 +64,7 @@ Delete the commented content.\n \n The comments are no longer in the catalog.\n \n- >>> browser.open(topic_url)\n+ >>> browser.open(collection_url)\n >>> browser.getLink(\'admin on Doc1\', index=0)\n Traceback (most recent call last):\n LinkNotFoundError\n' + +Repository: plone.app.discussion + + +Branch: refs/heads/main +Date: 2024-09-04T21:44:39+02:00 +Author: Maurits van Rees (mauritsvanrees) +Commit: https://github.com/plone/plone.app.discussion/commit/e08c5d87efe4fbb740264dafac62a45ddf05007c + +Merge pull request #244 from plone/maurits-globally-enable-comments + +Globally enable comments on install + +Files changed: +M news/211.breaking +M plone/app/discussion/interfaces.py +M plone/app/discussion/testing.py +M plone/app/discussion/tests/collection-integration-test.txt +M plone/app/discussion/tests/test_controlpanel.py + +b'diff --git a/news/211.breaking b/news/211.breaking\nindex f4cad3c5..62173580 100644\n--- a/news/211.breaking\n+++ b/news/211.breaking\n@@ -1,4 +1,5 @@\n Move this package in the space of Plone Core add-ons.\n It now depends on Products.CMFPlone and is no longer installed by default.\n It is still available in the default Plone distribution, but can be omitted in customizations.\n-[jensens]\n\\ No newline at end of file\n+Installing this in the Add-ons control panel will enable comments globally.\n+[jensens]\ndiff --git a/plone/app/discussion/interfaces.py b/plone/app/discussion/interfaces.py\nindex 5fca1385..eefa9c7d 100644\n--- a/plone/app/discussion/interfaces.py\n+++ b/plone/app/discussion/interfaces.py\n@@ -216,7 +216,7 @@ class IDiscussionSettings(Interface):\n "objects before users will be able to post comments.",\n ),\n required=False,\n- default=False,\n+ default=True,\n )\n \n anonymous_comments = schema.Bool(\ndiff --git a/plone/app/discussion/testing.py b/plone/app/discussion/testing.py\nindex 48a74392..83dafbb4 100644\n--- a/plone/app/discussion/testing.py\n+++ b/plone/app/discussion/testing.py\n@@ -1,5 +1,4 @@\n from plone.app.contenttypes.testing import PLONE_APP_CONTENTTYPES_FIXTURE\n-from plone.app.discussion.interfaces import IDiscussionSettings\n from plone.app.robotframework.testing import REMOTE_LIBRARY_ROBOT_TESTING\n from plone.app.testing import applyProfile\n from plone.app.testing import FunctionalTesting\n@@ -8,17 +7,7 @@\n from plone.app.testing import setRoles\n from plone.app.testing import TEST_USER_ID\n from plone.app.testing import TEST_USER_PASSWORD\n-from plone.registry.interfaces import IRegistry\n from Products.CMFCore.utils import getToolByName\n-from zope.component import queryUtility\n-\n-\n-try:\n- import plone.app.collection # noqa\n-\n- COLLECTION_TYPE = "Collection"\n-except ImportError:\n- COLLECTION_TYPE = "Topic"\n \n \n class PloneAppDiscussion(PloneSandboxLayer):\n@@ -105,12 +94,6 @@ class PloneAppDiscussionRobot(PloneAppDiscussion):\n REMOTE_LIBRARY_ROBOT_TESTING,\n )\n \n- def setUpPloneSite(self, portal):\n- applyProfile(portal, "plone.app.discussion:default")\n- registry = queryUtility(IRegistry)\n- settings = registry.forInterface(IDiscussionSettings)\n- settings.globally_enabled = True\n-\n \n PLONE_APP_DISCUSSION_ROBOT_FIXTURE = PloneAppDiscussionRobot()\n PLONE_APP_DISCUSSION_FIXTURE = PloneAppDiscussion()\ndiff --git a/plone/app/discussion/tests/collection-integration-test.txt b/plone/app/discussion/tests/collection-integration-test.txt\nindex c8814d43..b02c176b 100644\n--- a/plone/app/discussion/tests/collection-integration-test.txt\n+++ b/plone/app/discussion/tests/collection-integration-test.txt\n@@ -2,6 +2,8 @@ XXX: This functional test part has been removed due to the removal of\n ATContentTypes from PLONE_FIXTURE. We have to rewrite this test as a robot\n test because the dexterity collections do not work without js.\n \n+XXX To put this more plainly: this file is currently NOT tested.\n+\n \n List comments in a collection\n -----------------------------\n@@ -12,33 +14,24 @@ Create a collection.\n >>> from plone.app.testing import TEST_USER_NAME\n >>> setRoles(portal, \'manager\', [\'Manager\'])\n >>> browser.open(portal.absolute_url())\n- >>> from plone.app.discussion.testing import COLLECTION_TYPE\n- >>> browser.getLink(url=\'++add++\' + COLLECTION_TYPE).click()\n+ >>> browser.getLink(url=\'++add++Collection\').click()\n >>> open(\'/tmp/testbrowser.html\', \'w\').write(browser.contents)\n >>> browser.getControl(\'form.widgets.IDublinCore.title\').value = \'Foo Comment Collection\'\n >>> browser.getControl(\'Save\').click()\n >>> print(browser.contents)\n <...Changes saved...\n- >>> topic_url = browser.url\n+ >>> collection_url = browser.url\n \n Set the collection criteria.\n \n- >>> browser.open(topic_url + "/edit")\n+ >>> browser.open(collection_url + "/edit")\n \n- >>> if COLLECTION_TYPE == "Collection":\n- ... browser.getControl(name="addindex").value = [\'portal_type\']\n- ... browser.getControl(name="form.button.addcriteria").click()\n- ... browser.getControl(name="addoperator").value = [\'plone.app.querystring.operation.selection.any\']\n- ... browser.getControl(name="form.button.addcriteria").click()\n- ... browser.getControl(name="query.v:records:list").value = ["Discussion Item"]\n- ... browser.getControl(name="form.button.save").click()\n- ... else:\n- ... browser.getLink(\'Criteria\').click()\n- ... browser.getControl(\'Item Type\', index=0).selected = True\n- ... browser.getControl(\'Select content types\').selected = True\n- ... browser.getControl(\'Add criteria\').click()\n- ... browser.getControl(\'Comment\').selected = True\n- ... browser.getControl(\'Save\', index=0).click()\n+ >>> browser.getControl(name="addindex").value = [\'portal_type\']\n+ ... browser.getControl(name="form.button.addcriteria").click()\n+ ... browser.getControl(name="addoperator").value = [\'plone.app.querystring.operation.selection.any\']\n+ ... browser.getControl(name="form.button.addcriteria").click()\n+ ... browser.getControl(name="query.v:records:list").value = ["Discussion Item"]\n+ ... browser.getControl(name="form.button.save").click()\n >>> print(browser.contents)\n <...Changes saved...\n \n@@ -71,7 +64,7 @@ Delete the commented content.\n \n The comments are no longer in the catalog.\n \n- >>> browser.open(topic_url)\n+ >>> browser.open(collection_url)\n >>> browser.getLink(\'admin on Doc1\', index=0)\n Traceback (most recent call last):\n LinkNotFoundError\ndiff --git a/plone/app/discussion/tests/test_controlpanel.py b/plone/app/discussion/tests/test_controlpanel.py\nindex 25bb6a14..e2271dbe 100644\n--- a/plone/app/discussion/tests/test_controlpanel.py\n+++ b/plone/app/discussion/tests/test_controlpanel.py\n@@ -49,7 +49,7 @@ def test_globally_enabled(self):\n "plone.app.discussion.interfaces."\n + "IDiscussionSettings.globally_enabled"\n ],\n- False,\n+ True,\n )\n \n def test_anonymous_comments(self):\n'