Skip to content

Commit

Permalink
[fc] Repository: plone.app.iterate
Browse files Browse the repository at this point in the history
Branch: refs/heads/master
Date: 2021-09-08T12:08:33+02:00
Author: Érico Andrei (ericof) <ericof@gmail.com>
Commit: plone/plone.app.iterate@dfcea9d

Fix #97: Do not modify Publication behavior values when creating a new working copy.

Files changed:
A news/97.bugfix
M plone/app/iterate/dexterity/copier.py
M plone/app/iterate/tests/test_iterate.py
Repository: plone.app.iterate

Branch: refs/heads/master
Date: 2021-09-08T13:41:45+02:00
Author: Érico Andrei (ericof) <ericof@gmail.com>
Commit: plone/plone.app.iterate@ee89111

Merge pull request #98 from plone/issue-97-effective-date

Do not modify Publication behavior values when creating a new working copy

Files changed:
A news/97.bugfix
M plone/app/iterate/dexterity/copier.py
M plone/app/iterate/tests/test_iterate.py
  • Loading branch information
ericof committed Sep 8, 2021
1 parent 271e8b7 commit dab9764
Showing 1 changed file with 28 additions and 14 deletions.
42 changes: 28 additions & 14 deletions last_commit.txt
Original file line number Diff line number Diff line change
@@ -1,22 +1,36 @@
Repository: plone.restapi
Repository: plone.app.iterate


Branch: refs/heads/7.x.x
Date: 2021-09-02T08:03:32+02:00
Author: Wesley Barroso Lopes (wesleybl) <wesleybl@gmail.com>
Commit: https://github.com/plone/plone.restapi/commit/9ee759961cbbe57114075a0c44afdd84ffcc157a
Branch: refs/heads/master
Date: 2021-09-08T12:08:33+02:00
Author: Érico Andrei (ericof) <ericof@gmail.com>
Commit: https://github.com/plone/plone.app.iterate/commit/dfcea9d59ace798f8180f307c6afd488f8f55643

Fix tests that involving dates in Python 3.8 on machines that don't use (#1195) (#1213)
Fix #97: Do not modify Publication behavior values when creating a new working copy.

TZ = UTC

In Python 3.8, for the TZ environment variable to be recognized, you
need to call time.tzset()

Ref: https://github.com/plone/buildout.coredev/pull/701
Files changed:
A news/97.bugfix
M plone/app/iterate/dexterity/copier.py
M plone/app/iterate/tests/test_iterate.py

b'diff --git a/news/97.bugfix b/news/97.bugfix\nnew file mode 100644\nindex 0000000..dd16af8\n--- /dev/null\n+++ b/news/97.bugfix\n@@ -0,0 +1 @@\n+Fixed issue with Publication behavior fields having different values in the baseline and working copy [ericof]\n\\ No newline at end of file\ndiff --git a/plone/app/iterate/dexterity/copier.py b/plone/app/iterate/dexterity/copier.py\nindex d89a47f..2bc6995 100644\n--- a/plone/app/iterate/dexterity/copier.py\n+++ b/plone/app/iterate/dexterity/copier.py\n@@ -64,12 +64,10 @@ def _replaceBaseline(self, baseline):\n except Exception:\n value = None\n \n- # TODO: We need a way to identify the DCFieldProperty\n- # fields and use the appropriate set_name/get_name\n if name == "effective":\n- baseline.effective_date = self.context.effective()\n+ baseline.effective_date = self.context.effective_date\n elif name == "expires":\n- baseline.expiration_date = self.context.expires()\n+ baseline.expiration_date = self.context.expiration_date\n elif name == "subjects":\n baseline.setSubject(self.context.Subject())\n else:\n@@ -188,12 +186,10 @@ def _copyBaseline(self, container):\n except Exception:\n value = None\n \n- # TODO: We need a way to identify the DCFieldProperty\n- # fields and use the appropriate set_name/get_name\n if name == "effective":\n- obj.effective_date = self.context.effective()\n+ obj.effective_date = self.context.effective_date\n elif name == "expires":\n- obj.expiration_date = self.context.expires()\n+ obj.expiration_date = self.context.expiration_date\n elif name == "subjects":\n obj.setSubject(self.context.Subject())\n else:\n@@ -231,12 +227,10 @@ def _replaceBaseline(self, baseline):\n except Exception:\n value = None\n \n- # TODO: We need a way to identify the DCFieldProperty\n- # fields and use the appropriate set_name/get_name\n if name == "effective":\n- baseline.effective_date = self.context.effective()\n+ baseline.effective_date = self.context.effective_date\n elif name == "expires":\n- baseline.expiration_date = self.context.expires()\n+ baseline.expiration_date = self.context.expiration_date\n elif name == "subjects":\n baseline.setSubject(self.context.Subject())\n else:\ndiff --git a/plone/app/iterate/tests/test_iterate.py b/plone/app/iterate/tests/test_iterate.py\nindex f838f13..ecb4125 100644\n--- a/plone/app/iterate/tests/test_iterate.py\n+++ b/plone/app/iterate/tests/test_iterate.py\n@@ -21,6 +21,7 @@\n # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\n ##################################################################\n \n+from DateTime import DateTime\n from plone.app.iterate.browser.control import Control\n from plone.app.iterate.interfaces import ICheckinCheckoutPolicy\n from plone.app.iterate.testing import PLONEAPPITERATEDEX_INTEGRATION_TESTING\n@@ -51,6 +52,7 @@ def setUp(self):\n self.portal.invokeFactory("Folder", "docs")\n self.portal.docs.invokeFactory("Document", "doc1")\n self.portal.docs.invokeFactory("Document", "doc2")\n+ self.portal.docs.invokeFactory("FolderishDocument", "doc3")\n \n # add a working copy folder\n self.portal.invokeFactory("Folder", "workarea")\n@@ -262,3 +264,40 @@ def test_baseline_relations_updated_on_checkin(self):\n \n # new baseline\'s relatedItems should be empty\n self.assertEqual(len(rels), 0)\n+\n+ def test_publication_behavior_values_not_changed(self):\n+ doc = self.portal.docs.doc1\n+ original_effective_date = doc.effective_date\n+ original_expiration_date = doc.expiration_date\n+ # Create a working copy\n+ wc = ICheckinCheckoutPolicy(doc).checkout(self.portal.workarea)\n+ # Check in without modifying the existing values\n+ baseline = ICheckinCheckoutPolicy(wc).checkin("updated")\n+ # Values should be the same of the original document\n+ self.assertEqual(original_effective_date, baseline.effective_date)\n+ self.assertEqual(original_expiration_date, baseline.expiration_date)\n+\n+ def test_publication_behavior_values_not_changed_value_is_already_set(self):\n+ doc = self.portal.docs.doc2\n+ effective_date = DateTime("2021/09/08 10:06:00 UTC")\n+ doc.effective_date = effective_date\n+ original_expiration_date = doc.expiration_date\n+ # Create a working copy\n+ wc = ICheckinCheckoutPolicy(doc).checkout(self.portal.workarea)\n+ # Check in without modifying the existing values\n+ baseline = ICheckinCheckoutPolicy(wc).checkin("updated")\n+ # Values should be the same of the original document\n+ self.assertEqual(effective_date, baseline.effective_date)\n+ self.assertEqual(original_expiration_date, baseline.expiration_date)\n+\n+ def test_publication_behavior_values_not_changed_folderish(self):\n+ doc = self.portal.docs.doc3\n+ original_effective_date = doc.effective_date\n+ original_expiration_date = doc.expiration_date\n+ # Create a working copy\n+ wc = ICheckinCheckoutPolicy(doc).checkout(self.portal.workarea)\n+ # Check in without modifying the existing values\n+ baseline = ICheckinCheckoutPolicy(wc).checkin("updated")\n+ # Values should be the same of the original document\n+ self.assertEqual(original_effective_date, baseline.effective_date)\n+ self.assertEqual(original_expiration_date, baseline.expiration_date)\n'

Repository: plone.app.iterate


Branch: refs/heads/master
Date: 2021-09-08T13:41:45+02:00
Author: Érico Andrei (ericof) <ericof@gmail.com>
Commit: https://github.com/plone/plone.app.iterate/commit/ee89111f8380bf4ac040c5636e86abf750f9b398

Merge pull request #98 from plone/issue-97-effective-date

Do not modify Publication behavior values when creating a new working copy

Files changed:
M base.cfg
A news/97.bugfix
M plone/app/iterate/dexterity/copier.py
M plone/app/iterate/tests/test_iterate.py

b"diff --git a/base.cfg b/base.cfg\nindex cce28c3da..a27ef1d70 100644\n--- a/base.cfg\n+++ b/base.cfg\n@@ -66,6 +66,10 @@ recipe = zc.recipe.testrunner\n eggs = ${instance:eggs}\n initialization =\n os.environ['TZ'] = 'UTC'\n+ # In Python 3.8+, for the TZ environment variable to be used, it's \n+ # necessary to explicitly call time.tzset().\n+ import time\n+ time.tzset()\n os.environ['ZSERVER_PORT'] = '55001'\n defaults = ['-s', 'plone.restapi', '--auto-color', '--auto-progress']\n \n"
b'diff --git a/news/97.bugfix b/news/97.bugfix\nnew file mode 100644\nindex 0000000..dd16af8\n--- /dev/null\n+++ b/news/97.bugfix\n@@ -0,0 +1 @@\n+Fixed issue with Publication behavior fields having different values in the baseline and working copy [ericof]\n\\ No newline at end of file\ndiff --git a/plone/app/iterate/dexterity/copier.py b/plone/app/iterate/dexterity/copier.py\nindex d89a47f..2bc6995 100644\n--- a/plone/app/iterate/dexterity/copier.py\n+++ b/plone/app/iterate/dexterity/copier.py\n@@ -64,12 +64,10 @@ def _replaceBaseline(self, baseline):\n except Exception:\n value = None\n \n- # TODO: We need a way to identify the DCFieldProperty\n- # fields and use the appropriate set_name/get_name\n if name == "effective":\n- baseline.effective_date = self.context.effective()\n+ baseline.effective_date = self.context.effective_date\n elif name == "expires":\n- baseline.expiration_date = self.context.expires()\n+ baseline.expiration_date = self.context.expiration_date\n elif name == "subjects":\n baseline.setSubject(self.context.Subject())\n else:\n@@ -188,12 +186,10 @@ def _copyBaseline(self, container):\n except Exception:\n value = None\n \n- # TODO: We need a way to identify the DCFieldProperty\n- # fields and use the appropriate set_name/get_name\n if name == "effective":\n- obj.effective_date = self.context.effective()\n+ obj.effective_date = self.context.effective_date\n elif name == "expires":\n- obj.expiration_date = self.context.expires()\n+ obj.expiration_date = self.context.expiration_date\n elif name == "subjects":\n obj.setSubject(self.context.Subject())\n else:\n@@ -231,12 +227,10 @@ def _replaceBaseline(self, baseline):\n except Exception:\n value = None\n \n- # TODO: We need a way to identify the DCFieldProperty\n- # fields and use the appropriate set_name/get_name\n if name == "effective":\n- baseline.effective_date = self.context.effective()\n+ baseline.effective_date = self.context.effective_date\n elif name == "expires":\n- baseline.expiration_date = self.context.expires()\n+ baseline.expiration_date = self.context.expiration_date\n elif name == "subjects":\n baseline.setSubject(self.context.Subject())\n else:\ndiff --git a/plone/app/iterate/tests/test_iterate.py b/plone/app/iterate/tests/test_iterate.py\nindex f838f13..ecb4125 100644\n--- a/plone/app/iterate/tests/test_iterate.py\n+++ b/plone/app/iterate/tests/test_iterate.py\n@@ -21,6 +21,7 @@\n # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\n ##################################################################\n \n+from DateTime import DateTime\n from plone.app.iterate.browser.control import Control\n from plone.app.iterate.interfaces import ICheckinCheckoutPolicy\n from plone.app.iterate.testing import PLONEAPPITERATEDEX_INTEGRATION_TESTING\n@@ -51,6 +52,7 @@ def setUp(self):\n self.portal.invokeFactory("Folder", "docs")\n self.portal.docs.invokeFactory("Document", "doc1")\n self.portal.docs.invokeFactory("Document", "doc2")\n+ self.portal.docs.invokeFactory("FolderishDocument", "doc3")\n \n # add a working copy folder\n self.portal.invokeFactory("Folder", "workarea")\n@@ -262,3 +264,40 @@ def test_baseline_relations_updated_on_checkin(self):\n \n # new baseline\'s relatedItems should be empty\n self.assertEqual(len(rels), 0)\n+\n+ def test_publication_behavior_values_not_changed(self):\n+ doc = self.portal.docs.doc1\n+ original_effective_date = doc.effective_date\n+ original_expiration_date = doc.expiration_date\n+ # Create a working copy\n+ wc = ICheckinCheckoutPolicy(doc).checkout(self.portal.workarea)\n+ # Check in without modifying the existing values\n+ baseline = ICheckinCheckoutPolicy(wc).checkin("updated")\n+ # Values should be the same of the original document\n+ self.assertEqual(original_effective_date, baseline.effective_date)\n+ self.assertEqual(original_expiration_date, baseline.expiration_date)\n+\n+ def test_publication_behavior_values_not_changed_value_is_already_set(self):\n+ doc = self.portal.docs.doc2\n+ effective_date = DateTime("2021/09/08 10:06:00 UTC")\n+ doc.effective_date = effective_date\n+ original_expiration_date = doc.expiration_date\n+ # Create a working copy\n+ wc = ICheckinCheckoutPolicy(doc).checkout(self.portal.workarea)\n+ # Check in without modifying the existing values\n+ baseline = ICheckinCheckoutPolicy(wc).checkin("updated")\n+ # Values should be the same of the original document\n+ self.assertEqual(effective_date, baseline.effective_date)\n+ self.assertEqual(original_expiration_date, baseline.expiration_date)\n+\n+ def test_publication_behavior_values_not_changed_folderish(self):\n+ doc = self.portal.docs.doc3\n+ original_effective_date = doc.effective_date\n+ original_expiration_date = doc.expiration_date\n+ # Create a working copy\n+ wc = ICheckinCheckoutPolicy(doc).checkout(self.portal.workarea)\n+ # Check in without modifying the existing values\n+ baseline = ICheckinCheckoutPolicy(wc).checkin("updated")\n+ # Values should be the same of the original document\n+ self.assertEqual(original_effective_date, baseline.effective_date)\n+ self.assertEqual(original_expiration_date, baseline.expiration_date)\n'

0 comments on commit dab9764

Please sign in to comment.