Skip to content

Commit

Permalink
[fc] Repository: plone.app.contentmenu
Browse files Browse the repository at this point in the history
Branch: refs/heads/master
Date: 2023-08-18T10:45:20+02:00
Author: Sébastien Verbois (sverbois) <[email protected]>
Commit: plone/plone.app.contentmenu@fa43cb9

Fix #54 : "Add item to default page" modal form

Files changed:
A news/54.bugfix
M plone/app/contentmenu/menu.py
Repository: plone.app.contentmenu

Branch: refs/heads/master
Date: 2023-09-14T02:33:10+02:00
Author: Maurits van Rees (mauritsvanrees) <[email protected]>
Commit: plone/plone.app.contentmenu@3cc7261

Merge pull request #55 from plone/issue-54

Fix #54 : "Add item to default page" modal form

Files changed:
A news/54.bugfix
M plone/app/contentmenu/menu.py
  • Loading branch information
mauritsvanrees committed Sep 14, 2023
1 parent c74796d commit 1c8748b
Showing 1 changed file with 17 additions and 34 deletions.
51 changes: 17 additions & 34 deletions last_commit.txt
Original file line number Diff line number Diff line change
@@ -1,51 +1,34 @@
Repository: plone.namedfile
Repository: plone.app.contentmenu


Branch: refs/heads/master
Date: 2023-09-11T11:13:19-04:00
Author: Mathias Leimgruber (maethu) <[email protected]>
Commit: https://github.com/plone/plone.namedfile/commit/1511ce5d23a6210a096083ed02c76807becd9ef5
Date: 2023-08-18T10:45:20+02:00
Author: Sébastien Verbois (sverbois) <[email protected]>
Commit: https://github.com/plone/plone.app.contentmenu/commit/fa43cb9e35ca800f63f16b79ef5607d560e92367

Use new internal modification timestamp as part of the hash key for scales.
Fix #54 : "Add item to default page" modal form

Files changed:
A news/150.internal
M plone/namedfile/scaling.py
M plone/namedfile/tests/test_scaling.py
A news/54.bugfix
M plone/app/contentmenu/menu.py

b'diff --git a/news/150.internal b/news/150.internal\nnew file mode 100644\nindex 0000000..49f364f\n--- /dev/null\n+++ b/news/150.internal\n@@ -0,0 +1,2 @@\n+Use new internal modification timestamp as part of the hash key for scales.\n+[mathias.leimgruber]\ndiff --git a/plone/namedfile/scaling.py b/plone/namedfile/scaling.py\nindex 9ec3bd0..ffa064d 100644\n--- a/plone/namedfile/scaling.py\n+++ b/plone/namedfile/scaling.py\n@@ -524,8 +524,8 @@ def modified(self, fieldname=None):\n context = aq_base(self.context)\n if fieldname is not None:\n field = getattr(context, fieldname, None)\n- field_p_mtime = getattr(field, "_p_mtime", None)\n- date = DateTime(field_p_mtime or context._p_mtime)\n+ modified = getattr(field, "modified", None)\n+ date = DateTime(modified or context._p_mtime)\n else:\n date = DateTime(context._p_mtime)\n return date.millis()\ndiff --git a/plone/namedfile/tests/test_scaling.py b/plone/namedfile/tests/test_scaling.py\nindex 4159ebf..61c2499 100644\n--- a/plone/namedfile/tests/test_scaling.py\n+++ b/plone/namedfile/tests/test_scaling.py\n@@ -634,7 +634,6 @@ def testScaleInvalidation(self):\n \n # Test that different parameters give different scale\n self.item.modified = lambda: dt\n- self.item.image._p_mtime = dt.millis()\n scale1a = self.scaling.scale("image", width=100, height=80)\n scale2a = self.scaling.scale("image", width=80, height=60)\n self.assertNotEqual(scale1a.data, scale2a.data)\n@@ -647,13 +646,21 @@ def testScaleInvalidation(self):\n self.assertEqual(scale1a.data, scale1b.data)\n self.assertEqual(scale2a.data, scale2b.data)\n \n- # Test that field modification invalidates scales\n+ # Test changing _p_mtime on the field no longer invalidates a scale\n self.item.image._p_mtime = (dt + 1).millis()\n scale1b = self.scaling.scale("image", width=100, height=80)\n scale2b = self.scaling.scale("image", width=80, height=60)\n self.assertNotEqual(scale1b.data, scale2b.data)\n- self.assertNotEqual(scale1a.data, scale1b.data, "scale not updated?")\n- self.assertNotEqual(scale2a.data, scale2b.data, "scale not updated?")\n+ self.assertEqual(scale1a.data, scale1b.data)\n+ self.assertEqual(scale2a.data, scale2b.data)\n+\n+ # Test changing the fields modified timestamp invalidates scales\n+ self.item.image._modified = (dt + 1).millis()\n+ scale1c = self.scaling.scale("image", width=100, height=80)\n+ scale2c = self.scaling.scale("image", width=80, height=60)\n+ self.assertNotEqual(scale1c.data, scale2c.data)\n+ self.assertNotEqual(scale1a.data, scale1c.data, "scale not updated?")\n+ self.assertNotEqual(scale2a.data, scale2c.data, "scale not updated?")\n \n def testCustomSizeChange(self):\n # set custom image sizes & view a scale\n@@ -761,9 +768,11 @@ def testScaledJpegImageQuality(self):\n \n Image quality is not available for PNG images.\n """\n+ dt = DateTime()\n data = getFile("image.jpg")\n item = DummyContent()\n item.image = NamedImage(data, "image/png", "image.jpg")\n+ item.image.modified = dt.millis()\n scaling = ImageScaling(item, None)\n \n # scale an image, record its size\n@@ -774,7 +783,7 @@ def testScaledJpegImageQuality(self):\n gsm = getGlobalSiteManager()\n qualitySupplier = DummyQualitySupplier()\n gsm.registerUtility(qualitySupplier.getQuality, IScaledImageQuality)\n- wait_to_ensure_modified()\n+ item.image.modified = (dt + 1).millis()\n # now scale again\n bar = scaling.scale("image", width=100, height=80)\n size_bar = bar.data.getSize()\n'
b'diff --git a/news/54.bugfix b/news/54.bugfix\nnew file mode 100644\nindex 0000000..25e2bd2\n--- /dev/null\n+++ b/news/54.bugfix\n@@ -0,0 +1 @@\n+Fix "Add item to default page" modal form. [sverbois]\ndiff --git a/plone/app/contentmenu/menu.py b/plone/app/contentmenu/menu.py\nindex c2dc48e..e752899 100644\n--- a/plone/app/contentmenu/menu.py\n+++ b/plone/app/contentmenu/menu.py\n@@ -711,6 +711,9 @@ def getMenuItems(self, context, request):\n "id": "plone-contentmenu-add-to-default-page",\n "separator": None,\n "class": "pat-plone-modal",\n+ "modal": json.dumps(\n+ {"actionOptions": {"disableAjaxFormSubmit": True}}\n+ ),\n },\n "submenu": None,\n }\n'

Repository: plone.namedfile
Repository: plone.app.contentmenu


Branch: refs/heads/master
Date: 2023-09-11T11:14:12-04:00
Author: Mathias Leimgruber (maethu) <[email protected]>
Commit: https://github.com/plone/plone.namedfile/commit/5a4fe5a2e9a97a0affc31acc3022c8701c28bb83
Date: 2023-09-14T02:33:10+02:00
Author: Maurits van Rees (mauritsvanrees) <[email protected]>
Commit: https://github.com/plone/plone.app.contentmenu/commit/3cc72611dcf32abaf1928436d0804d00f23f525c

Add explicit fallback test to _p_time for scale invalidation.
Merge pull request #55 from plone/issue-54

Files changed:
M plone/namedfile/tests/test_scaling.py

b'diff --git a/plone/namedfile/tests/test_scaling.py b/plone/namedfile/tests/test_scaling.py\nindex 61c2499..c23846d 100644\n--- a/plone/namedfile/tests/test_scaling.py\n+++ b/plone/namedfile/tests/test_scaling.py\n@@ -662,6 +662,17 @@ def testScaleInvalidation(self):\n self.assertNotEqual(scale1a.data, scale1c.data, "scale not updated?")\n self.assertNotEqual(scale2a.data, scale2c.data, "scale not updated?")\n \n+ def testFallBackToDatabaseModifiedTimeStamp(self):\n+ dt = self.item.modified()\n+ scale_a = self.scaling.scale("image", width=100, height=80)\n+\n+ delattr(self.item.image, "_modified")\n+\n+ # Since there is no _modified timestamp, _p_mtime is the fallback.\n+ self.item.image._p_mtime = (dt + 1).millis()\n+ scale_b = self.scaling.scale("image", width=100, height=80)\n+ self.assertNotEqual(scale_a.data, scale_b.data)\n+\n def testCustomSizeChange(self):\n # set custom image sizes & view a scale\n self.scaling.available_sizes = {"foo": (23, 23)}\n@@ -772,7 +783,7 @@ def testScaledJpegImageQuality(self):\n data = getFile("image.jpg")\n item = DummyContent()\n item.image = NamedImage(data, "image/png", "image.jpg")\n- item.image.modified = dt.millis()\n+ item.image._modified = dt.millis()\n scaling = ImageScaling(item, None)\n \n # scale an image, record its size\n@@ -783,7 +794,7 @@ def testScaledJpegImageQuality(self):\n gsm = getGlobalSiteManager()\n qualitySupplier = DummyQualitySupplier()\n gsm.registerUtility(qualitySupplier.getQuality, IScaledImageQuality)\n- item.image.modified = (dt + 1).millis()\n+ item.image._modified = (dt + 1).millis()\n # now scale again\n bar = scaling.scale("image", width=100, height=80)\n size_bar = bar.data.getSize()\n'

Repository: plone.namedfile


Branch: refs/heads/master
Date: 2023-09-14T02:23:31+02:00
Author: Maurits van Rees (mauritsvanrees) <[email protected]>
Commit: https://github.com/plone/plone.namedfile/commit/afdf3c9175cd9430bf5b52ea6423a60d4aa8aced

Merge pull request #152 from plone/mle-new-timestamp-for-hash_key

Use new internal modification timestamp as part of the hash key for scales.
Fix #54 : "Add item to default page" modal form

Files changed:
A news/150.internal
M plone/namedfile/scaling.py
M plone/namedfile/tests/test_scaling.py
A news/54.bugfix
M plone/app/contentmenu/menu.py

b'diff --git a/news/150.internal b/news/150.internal\nnew file mode 100644\nindex 0000000..49f364f\n--- /dev/null\n+++ b/news/150.internal\n@@ -0,0 +1,2 @@\n+Use new internal modification timestamp as part of the hash key for scales.\n+[mathias.leimgruber]\ndiff --git a/plone/namedfile/scaling.py b/plone/namedfile/scaling.py\nindex 9ec3bd0..ffa064d 100644\n--- a/plone/namedfile/scaling.py\n+++ b/plone/namedfile/scaling.py\n@@ -524,8 +524,8 @@ def modified(self, fieldname=None):\n context = aq_base(self.context)\n if fieldname is not None:\n field = getattr(context, fieldname, None)\n- field_p_mtime = getattr(field, "_p_mtime", None)\n- date = DateTime(field_p_mtime or context._p_mtime)\n+ modified = getattr(field, "modified", None)\n+ date = DateTime(modified or context._p_mtime)\n else:\n date = DateTime(context._p_mtime)\n return date.millis()\ndiff --git a/plone/namedfile/tests/test_scaling.py b/plone/namedfile/tests/test_scaling.py\nindex 4159ebf..c23846d 100644\n--- a/plone/namedfile/tests/test_scaling.py\n+++ b/plone/namedfile/tests/test_scaling.py\n@@ -634,7 +634,6 @@ def testScaleInvalidation(self):\n \n # Test that different parameters give different scale\n self.item.modified = lambda: dt\n- self.item.image._p_mtime = dt.millis()\n scale1a = self.scaling.scale("image", width=100, height=80)\n scale2a = self.scaling.scale("image", width=80, height=60)\n self.assertNotEqual(scale1a.data, scale2a.data)\n@@ -647,13 +646,32 @@ def testScaleInvalidation(self):\n self.assertEqual(scale1a.data, scale1b.data)\n self.assertEqual(scale2a.data, scale2b.data)\n \n- # Test that field modification invalidates scales\n+ # Test changing _p_mtime on the field no longer invalidates a scale\n self.item.image._p_mtime = (dt + 1).millis()\n scale1b = self.scaling.scale("image", width=100, height=80)\n scale2b = self.scaling.scale("image", width=80, height=60)\n self.assertNotEqual(scale1b.data, scale2b.data)\n- self.assertNotEqual(scale1a.data, scale1b.data, "scale not updated?")\n- self.assertNotEqual(scale2a.data, scale2b.data, "scale not updated?")\n+ self.assertEqual(scale1a.data, scale1b.data)\n+ self.assertEqual(scale2a.data, scale2b.data)\n+\n+ # Test changing the fields modified timestamp invalidates scales\n+ self.item.image._modified = (dt + 1).millis()\n+ scale1c = self.scaling.scale("image", width=100, height=80)\n+ scale2c = self.scaling.scale("image", width=80, height=60)\n+ self.assertNotEqual(scale1c.data, scale2c.data)\n+ self.assertNotEqual(scale1a.data, scale1c.data, "scale not updated?")\n+ self.assertNotEqual(scale2a.data, scale2c.data, "scale not updated?")\n+\n+ def testFallBackToDatabaseModifiedTimeStamp(self):\n+ dt = self.item.modified()\n+ scale_a = self.scaling.scale("image", width=100, height=80)\n+\n+ delattr(self.item.image, "_modified")\n+\n+ # Since there is no _modified timestamp, _p_mtime is the fallback.\n+ self.item.image._p_mtime = (dt + 1).millis()\n+ scale_b = self.scaling.scale("image", width=100, height=80)\n+ self.assertNotEqual(scale_a.data, scale_b.data)\n \n def testCustomSizeChange(self):\n # set custom image sizes & view a scale\n@@ -761,9 +779,11 @@ def testScaledJpegImageQuality(self):\n \n Image quality is not available for PNG images.\n """\n+ dt = DateTime()\n data = getFile("image.jpg")\n item = DummyContent()\n item.image = NamedImage(data, "image/png", "image.jpg")\n+ item.image._modified = dt.millis()\n scaling = ImageScaling(item, None)\n \n # scale an image, record its size\n@@ -774,7 +794,7 @@ def testScaledJpegImageQuality(self):\n gsm = getGlobalSiteManager()\n qualitySupplier = DummyQualitySupplier()\n gsm.registerUtility(qualitySupplier.getQuality, IScaledImageQuality)\n- wait_to_ensure_modified()\n+ item.image._modified = (dt + 1).millis()\n # now scale again\n bar = scaling.scale("image", width=100, height=80)\n size_bar = bar.data.getSize()\n'
b'diff --git a/news/54.bugfix b/news/54.bugfix\nnew file mode 100644\nindex 0000000..25e2bd2\n--- /dev/null\n+++ b/news/54.bugfix\n@@ -0,0 +1 @@\n+Fix "Add item to default page" modal form. [sverbois]\ndiff --git a/plone/app/contentmenu/menu.py b/plone/app/contentmenu/menu.py\nindex c2dc48e..e752899 100644\n--- a/plone/app/contentmenu/menu.py\n+++ b/plone/app/contentmenu/menu.py\n@@ -711,6 +711,9 @@ def getMenuItems(self, context, request):\n "id": "plone-contentmenu-add-to-default-page",\n "separator": None,\n "class": "pat-plone-modal",\n+ "modal": json.dumps(\n+ {"actionOptions": {"disableAjaxFormSubmit": True}}\n+ ),\n },\n "submenu": None,\n }\n'

0 comments on commit 1c8748b

Please sign in to comment.