From 3c6cdeb506f92c670631c0e7c5d1c9306ec5cddb Mon Sep 17 00:00:00 2001 From: mauritsvanrees Date: Fri, 26 Jul 2024 22:02:51 +0200 Subject: [PATCH] [fc] Repository: plone.app.testing Branch: refs/heads/master Date: 2024-06-19T21:48:44+02:00 Author: Maurits van Rees (mauritsvanrees) Commit: https://github.com/plone/plone.app.testing/commit/89dfa1db45c537ba9e6e8039aef49f33d0d65c21 PloneFixture: explicitly install plone.app.contenttypes:default. The `addPloneSite` factory in Plone 6.1 no longer installs this by default. See https://github.com/plone/Products.CMFPlone/issues/3961 Files changed: A news/3961.feature M src/plone/app/testing/layers.py Repository: plone.app.testing Branch: refs/heads/master Date: 2024-07-26T22:02:51+02:00 Author: Maurits van Rees (mauritsvanrees) Commit: https://github.com/plone/plone.app.testing/commit/72970c70321e3331bfe75a8424237cff4b7758ea Merge pull request #97 from plone/distributions PloneFixture: explicitly install plone.app.contenttypes:default. Files changed: A news/3961.feature M src/plone/app/testing/layers.py --- last_commit.txt | 96 ++++++++++--------------------------------------- 1 file changed, 19 insertions(+), 77 deletions(-) diff --git a/last_commit.txt b/last_commit.txt index e7a9bec795..b0e2478141 100644 --- a/last_commit.txt +++ b/last_commit.txt @@ -1,95 +1,37 @@ -Repository: plone.app.event +Repository: plone.app.testing Branch: refs/heads/master -Date: 2024-07-18T12:09:43+02:00 -Author: Mikel Larreategi (erral) -Commit: https://github.com/plone/plone.app.event/commit/8e5ab78a30da39d81048d6b59b737125837b7d22 +Date: 2024-06-19T21:48:44+02:00 +Author: Maurits van Rees (mauritsvanrees) +Commit: https://github.com/plone/plone.app.testing/commit/89dfa1db45c537ba9e6e8039aef49f33d0d65c21 -add tests +PloneFixture: explicitly install plone.app.contenttypes:default. -Files changed: -M plone/app/event/tests/test_portlet_calendar.py - -b'diff --git a/plone/app/event/tests/test_portlet_calendar.py b/plone/app/event/tests/test_portlet_calendar.py\nindex 8b96a1d3..20a916e1 100644\n--- a/plone/app/event/tests/test_portlet_calendar.py\n+++ b/plone/app/event/tests/test_portlet_calendar.py\n@@ -269,3 +269,91 @@ def test_invalid_request(self):\n r.update()\n today = localized_today(self.portal)\n self.assertEqual(r.year_month_display(), (today.year, today.month))\n+\n+ def test_with_collection_as_source(self):\n+ """When selecting a Collection as source, the events in that collection\n+ are used to build the calendar\n+ """\n+ tz = pytz.timezone(TZNAME)\n+ start = tz.localize(datetime.now())\n+ end = start + timedelta(hours=1)\n+\n+ e1 = createContentInContainer(\n+ self.portal, PTYPE, title="e1", start=start, end=end\n+ )\n+ self.portal.invokeFactory("Folder", "eventfolder")\n+ createContentInContainer(\n+ self.portal.eventfolder, PTYPE, title="e2", start=start, end=end\n+ )\n+ self.portal.portal_workflow.doActionFor(e1, "publish")\n+\n+ self.portal.invokeFactory(\n+ "Collection",\n+ "eventcollection",\n+ query=[\n+ {\n+ "i": "portal_type",\n+ "o": "plone.app.querystring.operation.selection.any",\n+ "v": ["Event"],\n+ },\n+ {\n+ "i": "end",\n+ "o": "plone.app.querystring.operation.date.afterToday",\n+ "v": "",\n+ },\n+ ],\n+ )\n+ self.portal\n+\n+ r = self.renderer(\n+ assignment=portlet_calendar.Assignment(\n+ state=("draft",), search_base_uid=self.portal.eventcollection.UID()\n+ )\n+ )\n+ r.update()\n+ rd = r.render()\n+ self.assertTrue("e1" not in rd and "e2" not in rd)\n+\n+ r = self.renderer(\n+ assignment=portlet_calendar.Assignment(\n+ state=("published",), search_base_uid=self.portal.eventcollection.UID()\n+ )\n+ )\n+ r.update()\n+ rd = r.render()\n+ self.assertTrue("e1" in rd and "e2" not in rd)\n+\n+ r = self.renderer(\n+ assignment=portlet_calendar.Assignment(\n+ state=(\n+ "published",\n+ "private",\n+ )\n+ )\n+ )\n+ r.update()\n+ rd = r.render()\n+ self.assertTrue("e1" in rd and "e2" in rd)\n+\n+ r = self.renderer(assignment=portlet_calendar.Assignment())\n+ r.update()\n+ rd = r.render()\n+ self.assertTrue("e1" in rd and "e2" in rd)\n+\n+ # No search base gives calendar urls with event_listing part\n+ self.assertTrue("event_listing?mode=day" in rd)\n+\n+ r = self.renderer(\n+ assignment=portlet_calendar.Assignment(\n+ search_base_uid=self.portal.eventfolder.UID()\n+ )\n+ )\n+ r.update()\n+ rd = r.render()\n+ self.assertTrue("e1" not in rd and "e2" in rd)\n+\n+ # A given search base gives calendar urls without event_listing part\n+ self.assertTrue("event_listing?mode=day" not in rd)\n+\n+ # link to calendar view in rendering\n+ self.assertTrue("?mode=day&date=" in rd)\n' - -Repository: plone.app.event - - -Branch: refs/heads/master -Date: 2024-07-22T11:46:20+02:00 -Author: Mikel Larreategi (erral) -Commit: https://github.com/plone/plone.app.event/commit/33a4edc7ddedb0934d4f32e73dbf654c7fea78af - -test calendar portlet when configured item is a collection - -Files changed: -M plone/app/event/portlets/portlet_calendar.py -M plone/app/event/tests/test_portlet_calendar.py - -b'diff --git a/plone/app/event/portlets/portlet_calendar.py b/plone/app/event/portlets/portlet_calendar.py\nindex cfd4d21d..e9edf647 100644\n--- a/plone/app/event/portlets/portlet_calendar.py\n+++ b/plone/app/event/portlets/portlet_calendar.py\n@@ -26,8 +26,10 @@\n from zope.component.hooks import getSite\n from zope.i18nmessageid import MessageFactory\n from zope.interface import implementer\n+from DateTime import DateTime\n \n import calendar\n+import datetime\n import json\n \n \n@@ -211,14 +213,13 @@ def cal_data(self):\n sort_order=None,\n )\n \n- # restrict start/end with those from query, if given.\n- if "start" in query and query["start"] > start:\n- start = query["start"]\n- if "end" in query and query["end"] < end:\n- end = query["end"]\n-\n+ # When having a collection as context, we should use the configured query\n+ # except the start and the end, which should be\n+ # taken from the current calendar start and end\n start, end = _prepare_range(self.search_base, start, end)\n- query.update(start_end_query(start, end))\n+ query.update(\n+ start_end_query(DateTime(start.isoformat()), DateTime(end.isoformat()))\n+ )\n events = self.search_base.results(\n batch=False, brains=True, custom_query=query\n )\ndiff --git a/plone/app/event/tests/test_portlet_calendar.py b/plone/app/event/tests/test_portlet_calendar.py\nindex 20a916e1..176a92c2 100644\n--- a/plone/app/event/tests/test_portlet_calendar.py\n+++ b/plone/app/event/tests/test_portlet_calendar.py\n@@ -278,14 +278,64 @@ def test_with_collection_as_source(self):\n start = tz.localize(datetime.now())\n end = start + timedelta(hours=1)\n \n- e1 = createContentInContainer(\n- self.portal, PTYPE, title="e1", start=start, end=end\n+ createContentInContainer(self.portal, PTYPE, title="e1", start=start, end=end)\n+\n+ createContentInContainer(self.portal, PTYPE, title="e2", start=start, end=end)\n+\n+ # starts yesterday, ends yesterday\n+ start_yesterday = tz.localize(datetime.now() - timedelta(days=1))\n+ end_yesterday = start + timedelta(hours=1)\n+\n+ createContentInContainer(\n+ self.portal,\n+ PTYPE,\n+ title="e3",\n+ start=start_yesterday,\n+ end=end_yesterday,\n )\n- self.portal.invokeFactory("Folder", "eventfolder")\n+\n+ # starts today, ends tomorrow\n+ start_today = tz.localize(datetime.now())\n+ end_tomorrow = start + timedelta(days=1)\n+\n createContentInContainer(\n- self.portal.eventfolder, PTYPE, title="e2", start=start, end=end\n+ self.portal,\n+ PTYPE,\n+ title="e4",\n+ start=start_today,\n+ end=end_tomorrow,\n )\n- self.portal.portal_workflow.doActionFor(e1, "publish")\n+\n+ # starts yesterday, ends tomorrow\n+ start_yesterday = tz.localize(datetime.now() - timedelta(days=1))\n+ end_tomorrow = tz.localize(datetime.now()) + timedelta(days=1)\n+\n+ createContentInContainer(\n+ self.portal,\n+ PTYPE,\n+ title="e5",\n+ start=start_yesterday,\n+ end=end_tomorrow,\n+ )\n+\n+ # starts tomorrow, ends tomorrow + 1\n+ start_tomorrow = tz.localize(datetime.now() + timedelta(days=1))\n+ end_tomorrow_1 = start_tomorrow + timedelta(days=1)\n+\n+ createContentInContainer(\n+ self.portal,\n+ PTYPE,\n+ title="e6",\n+ start=start_tomorrow,\n+ end=end_tomorrow_1,\n+ )\n+\n+ # self.wft.doActionFor(self.portal.e1, "publish")\n+ self.wft.doActionFor(self.portal.e2, "publish")\n+ self.wft.doActionFor(self.portal.e3, "publish")\n+ self.wft.doActionFor(self.portal.e4, "publish")\n+ self.wft.doActionFor(self.portal.e5, "publish")\n+ self.wft.doActionFor(self.portal.e6, "publish")\n \n self.portal.invokeFactory(\n "Collection",\n@@ -294,66 +344,34 @@ def test_with_collection_as_source(self):\n {\n "i": "portal_type",\n "o": "plone.app.querystring.operation.selection.any",\n- "v": ["Event"],\n+ "v": [PTYPE],\n },\n {\n "i": "end",\n "o": "plone.app.querystring.operation.date.afterToday",\n "v": "",\n },\n+ {\n+ "i": "review_state",\n+ "o": "plone.app.querystring.operation.selection.any",\n+ "v": ["published"],\n+ },\n ],\n )\n- self.portal\n-\n- r = self.renderer(\n- assignment=portlet_calendar.Assignment(\n- state=("draft",), search_base_uid=self.portal.eventcollection.UID()\n- )\n- )\n- r.update()\n- rd = r.render()\n- self.assertTrue("e1" not in rd and "e2" not in rd)\n-\n- r = self.renderer(\n- assignment=portlet_calendar.Assignment(\n- state=("published",), search_base_uid=self.portal.eventcollection.UID()\n- )\n- )\n- r.update()\n- rd = r.render()\n- self.assertTrue("e1" in rd and "e2" not in rd)\n-\n- r = self.renderer(\n- assignment=portlet_calendar.Assignment(\n- state=(\n- "published",\n- "private",\n- )\n- )\n- )\n- r.update()\n- rd = r.render()\n- self.assertTrue("e1" in rd and "e2" in rd)\n-\n- r = self.renderer(assignment=portlet_calendar.Assignment())\n- r.update()\n- rd = r.render()\n- self.assertTrue("e1" in rd and "e2" in rd)\n-\n- # No search base gives calendar urls with event_listing part\n- self.assertTrue("event_listing?mode=day" in rd)\n \n r = self.renderer(\n+ # context=self.portal.eventcollection,\n assignment=portlet_calendar.Assignment(\n- search_base_uid=self.portal.eventfolder.UID()\n- )\n+ state=("published",),\n+ search_base_uid=self.portal.eventcollection.UID(),\n+ ),\n )\n r.update()\n rd = r.render()\n- self.assertTrue("e1" not in rd and "e2" in rd)\n-\n- # A given search base gives calendar urls without event_listing part\n- self.assertTrue("event_listing?mode=day" not in rd)\n \n- # link to calendar view in rendering\n- self.assertTrue("?mode=day&date=" in rd)\n+ self.assertTrue("e1" not in rd)\n+ self.assertTrue("e2" in rd)\n+ self.assertTrue("e3" in rd)\n+ self.assertTrue("e4" in rd)\n+ self.assertTrue("e5" in rd)\n+ self.assertTrue("e6" in rd)\n' - -Repository: plone.app.event - - -Branch: refs/heads/master -Date: 2024-07-22T11:47:51+02:00 -Author: Mikel Larreategi (erral) -Commit: https://github.com/plone/plone.app.event/commit/fd8d96ad30729f8a22c85e1a1d1e294ec6f262ad - -isort - -Files changed: -M plone/app/event/portlets/portlet_calendar.py - -b'diff --git a/plone/app/event/portlets/portlet_calendar.py b/plone/app/event/portlets/portlet_calendar.py\nindex e9edf647..e47d7d62 100644\n--- a/plone/app/event/portlets/portlet_calendar.py\n+++ b/plone/app/event/portlets/portlet_calendar.py\n@@ -1,5 +1,6 @@\n from Acquisition import aq_inner\n from ComputedAttribute import ComputedAttribute\n+from DateTime import DateTime\n from plone.app.contenttypes.behaviors.collection import ISyndicatableCollection\n from plone.app.contenttypes.interfaces import IFolder\n from plone.app.event import _\n@@ -26,7 +27,6 @@\n from zope.component.hooks import getSite\n from zope.i18nmessageid import MessageFactory\n from zope.interface import implementer\n-from DateTime import DateTime\n \n import calendar\n import datetime\n' - -Repository: plone.app.event - - -Branch: refs/heads/master -Date: 2024-07-22T11:49:14+02:00 -Author: Mikel Larreategi (erral) -Commit: https://github.com/plone/plone.app.event/commit/49edfa6d8554159a91e1e095a6df83b7ecfa3fb4 - -changelog - -Files changed: -A news/399.bugfix - -b'diff --git a/news/399.bugfix b/news/399.bugfix\nnew file mode 100644\nindex 000000000..adba3539f\n--- /dev/null\n+++ b/news/399.bugfix\n@@ -0,0 +1 @@\n+Fix calendar portlet to work when selected item is a Collection [erral]\n' - -Repository: plone.app.event - - -Branch: refs/heads/master -Date: 2024-07-22T11:51:50+02:00 -Author: Mikel Larreategi (erral) -Commit: https://github.com/plone/plone.app.event/commit/bfee507928b1916c5616e581770aec4dcea21646 - -unneeded +The `addPloneSite` factory in Plone 6.1 no longer installs this by default. +See https://github.com/plone/Products.CMFPlone/issues/3961 Files changed: -M plone/app/event/portlets/portlet_calendar.py +A news/3961.feature +M src/plone/app/testing/layers.py -b'diff --git a/plone/app/event/portlets/portlet_calendar.py b/plone/app/event/portlets/portlet_calendar.py\nindex e47d7d62..b5ff6e01 100644\n--- a/plone/app/event/portlets/portlet_calendar.py\n+++ b/plone/app/event/portlets/portlet_calendar.py\n@@ -1,6 +1,5 @@\n from Acquisition import aq_inner\n from ComputedAttribute import ComputedAttribute\n-from DateTime import DateTime\n from plone.app.contenttypes.behaviors.collection import ISyndicatableCollection\n from plone.app.contenttypes.interfaces import IFolder\n from plone.app.event import _\n@@ -29,7 +28,6 @@\n from zope.interface import implementer\n \n import calendar\n-import datetime\n import json\n \n \n@@ -217,9 +215,7 @@ def cal_data(self):\n # except the start and the end, which should be\n # taken from the current calendar start and end\n start, end = _prepare_range(self.search_base, start, end)\n- query.update(\n- start_end_query(DateTime(start.isoformat()), DateTime(end.isoformat()))\n- )\n+ query.update(start_end_query(start, end))\n events = self.search_base.results(\n batch=False, brains=True, custom_query=query\n )\n' +b'diff --git a/news/3961.feature b/news/3961.feature\nnew file mode 100644\nindex 0000000..2c653dc\n--- /dev/null\n+++ b/news/3961.feature\n@@ -0,0 +1,4 @@\n+PloneFixture: explicitly install plone.app.contenttypes:default.\n+The `addPloneSite` factory in Plone 6.1 no longer installs this by default.\n+[maurits]\n+\ndiff --git a/src/plone/app/testing/layers.py b/src/plone/app/testing/layers.py\nindex e1eb75b..6b787c3 100644\n--- a/src/plone/app/testing/layers.py\n+++ b/src/plone/app/testing/layers.py\n@@ -70,7 +70,10 @@ class PloneFixture(Layer):\n )\n \n # Extension profiles to be installed with site setup\n- extensionProfiles = ("plonetheme.barceloneta:default",)\n+ extensionProfiles = (\n+ "plone.app.contenttypes:default",\n+ "plonetheme.barceloneta:default",\n+ )\n \n # Layer lifecycle\n \n' -Repository: plone.app.event +Repository: plone.app.testing Branch: refs/heads/master -Date: 2024-07-23T21:21:52-07:00 -Author: David Glick (davisagli) -Commit: https://github.com/plone/plone.app.event/commit/3608882f01847f8d9596caae4bb567cc3421cfc9 +Date: 2024-07-26T22:02:51+02:00 +Author: Maurits van Rees (mauritsvanrees) +Commit: https://github.com/plone/plone.app.testing/commit/72970c70321e3331bfe75a8424237cff4b7758ea -Merge pull request #400 from plone/erral-issue-399 +Merge pull request #97 from plone/distributions -Fix calendar portlet to work when selected item is a Collection +PloneFixture: explicitly install plone.app.contenttypes:default. Files changed: -A news/399.bugfix -M plone/app/event/portlets/portlet_calendar.py -M plone/app/event/tests/test_portlet_calendar.py +A news/3961.feature +M src/plone/app/testing/layers.py -b'diff --git a/news/399.bugfix b/news/399.bugfix\nnew file mode 100644\nindex 000000000..adba3539f\n--- /dev/null\n+++ b/news/399.bugfix\n@@ -0,0 +1 @@\n+Fix calendar portlet to work when selected item is a Collection [erral]\ndiff --git a/plone/app/event/portlets/portlet_calendar.py b/plone/app/event/portlets/portlet_calendar.py\nindex cfd4d21d8..b5ff6e011 100644\n--- a/plone/app/event/portlets/portlet_calendar.py\n+++ b/plone/app/event/portlets/portlet_calendar.py\n@@ -211,12 +211,9 @@ def cal_data(self):\n sort_order=None,\n )\n \n- # restrict start/end with those from query, if given.\n- if "start" in query and query["start"] > start:\n- start = query["start"]\n- if "end" in query and query["end"] < end:\n- end = query["end"]\n-\n+ # When having a collection as context, we should use the configured query\n+ # except the start and the end, which should be\n+ # taken from the current calendar start and end\n start, end = _prepare_range(self.search_base, start, end)\n query.update(start_end_query(start, end))\n events = self.search_base.results(\ndiff --git a/plone/app/event/tests/test_portlet_calendar.py b/plone/app/event/tests/test_portlet_calendar.py\nindex 8b96a1d3a..176a92c23 100644\n--- a/plone/app/event/tests/test_portlet_calendar.py\n+++ b/plone/app/event/tests/test_portlet_calendar.py\n@@ -269,3 +269,109 @@ def test_invalid_request(self):\n r.update()\n today = localized_today(self.portal)\n self.assertEqual(r.year_month_display(), (today.year, today.month))\n+\n+ def test_with_collection_as_source(self):\n+ """When selecting a Collection as source, the events in that collection\n+ are used to build the calendar\n+ """\n+ tz = pytz.timezone(TZNAME)\n+ start = tz.localize(datetime.now())\n+ end = start + timedelta(hours=1)\n+\n+ createContentInContainer(self.portal, PTYPE, title="e1", start=start, end=end)\n+\n+ createContentInContainer(self.portal, PTYPE, title="e2", start=start, end=end)\n+\n+ # starts yesterday, ends yesterday\n+ start_yesterday = tz.localize(datetime.now() - timedelta(days=1))\n+ end_yesterday = start + timedelta(hours=1)\n+\n+ createContentInContainer(\n+ self.portal,\n+ PTYPE,\n+ title="e3",\n+ start=start_yesterday,\n+ end=end_yesterday,\n+ )\n+\n+ # starts today, ends tomorrow\n+ start_today = tz.localize(datetime.now())\n+ end_tomorrow = start + timedelta(days=1)\n+\n+ createContentInContainer(\n+ self.portal,\n+ PTYPE,\n+ title="e4",\n+ start=start_today,\n+ end=end_tomorrow,\n+ )\n+\n+ # starts yesterday, ends tomorrow\n+ start_yesterday = tz.localize(datetime.now() - timedelta(days=1))\n+ end_tomorrow = tz.localize(datetime.now()) + timedelta(days=1)\n+\n+ createContentInContainer(\n+ self.portal,\n+ PTYPE,\n+ title="e5",\n+ start=start_yesterday,\n+ end=end_tomorrow,\n+ )\n+\n+ # starts tomorrow, ends tomorrow + 1\n+ start_tomorrow = tz.localize(datetime.now() + timedelta(days=1))\n+ end_tomorrow_1 = start_tomorrow + timedelta(days=1)\n+\n+ createContentInContainer(\n+ self.portal,\n+ PTYPE,\n+ title="e6",\n+ start=start_tomorrow,\n+ end=end_tomorrow_1,\n+ )\n+\n+ # self.wft.doActionFor(self.portal.e1, "publish")\n+ self.wft.doActionFor(self.portal.e2, "publish")\n+ self.wft.doActionFor(self.portal.e3, "publish")\n+ self.wft.doActionFor(self.portal.e4, "publish")\n+ self.wft.doActionFor(self.portal.e5, "publish")\n+ self.wft.doActionFor(self.portal.e6, "publish")\n+\n+ self.portal.invokeFactory(\n+ "Collection",\n+ "eventcollection",\n+ query=[\n+ {\n+ "i": "portal_type",\n+ "o": "plone.app.querystring.operation.selection.any",\n+ "v": [PTYPE],\n+ },\n+ {\n+ "i": "end",\n+ "o": "plone.app.querystring.operation.date.afterToday",\n+ "v": "",\n+ },\n+ {\n+ "i": "review_state",\n+ "o": "plone.app.querystring.operation.selection.any",\n+ "v": ["published"],\n+ },\n+ ],\n+ )\n+\n+ r = self.renderer(\n+ # context=self.portal.eventcollection,\n+ assignment=portlet_calendar.Assignment(\n+ state=("published",),\n+ search_base_uid=self.portal.eventcollection.UID(),\n+ ),\n+ )\n+ r.update()\n+ rd = r.render()\n+\n+ self.assertTrue("e1" not in rd)\n+ self.assertTrue("e2" in rd)\n+ self.assertTrue("e3" in rd)\n+ self.assertTrue("e4" in rd)\n+ self.assertTrue("e5" in rd)\n+ self.assertTrue("e6" in rd)\n' +b'diff --git a/news/3961.feature b/news/3961.feature\nnew file mode 100644\nindex 0000000..2c653dc\n--- /dev/null\n+++ b/news/3961.feature\n@@ -0,0 +1,4 @@\n+PloneFixture: explicitly install plone.app.contenttypes:default.\n+The `addPloneSite` factory in Plone 6.1 no longer installs this by default.\n+[maurits]\n+\ndiff --git a/src/plone/app/testing/layers.py b/src/plone/app/testing/layers.py\nindex e1eb75b..6b787c3 100644\n--- a/src/plone/app/testing/layers.py\n+++ b/src/plone/app/testing/layers.py\n@@ -70,7 +70,10 @@ class PloneFixture(Layer):\n )\n \n # Extension profiles to be installed with site setup\n- extensionProfiles = ("plonetheme.barceloneta:default",)\n+ extensionProfiles = (\n+ "plone.app.contenttypes:default",\n+ "plonetheme.barceloneta:default",\n+ )\n \n # Layer lifecycle\n \n'