-
-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Branch: refs/heads/master Date: 2021-10-08T16:51:24+02:00 Author: Érico Andrei (ericof) <ericof@gmail.com> Commit: plone/plone.locking@780f9b6 Register a fallback @@plone_lock_info view to allow objects without plone.locking behavior to be edited. Files changed: A news/3331.fix A plone/locking/tests/test_views.py M plone/locking/browser/locking.py M plone/locking/configure.zcml Repository: plone.locking Branch: refs/heads/master Date: 2021-10-08T23:33:43+02:00 Author: Maurits van Rees (mauritsvanrees) <m.van.rees@zestsoftware.nl> Commit: plone/plone.locking@16f1321 Merge pull request #18 from plone/issue-3331-removing-lock-behavior Add fallback plone_lock_info view Files changed: A news/3331.fix A plone/locking/tests/test_views.py M plone/locking/browser/locking.py M plone/locking/configure.zcml
- Loading branch information
1 parent
0bc488e
commit 18229d2
Showing
1 changed file
with
21 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,38 @@ | ||
Repository: plone.app.users | ||
Repository: plone.locking | ||
|
||
|
||
Branch: refs/heads/master | ||
Date: 2021-10-07T17:22:41+02:00 | ||
Author: Jens W. Klein (jensens) <jk@kleinundpartner.at> | ||
Commit: https://github.com/plone/plone.app.users/commit/db322f08598fc19ad56a531db851c5740c339106 | ||
Date: 2021-10-08T16:51:24+02:00 | ||
Author: Érico Andrei (ericof) <ericof@gmail.com> | ||
Commit: https://github.com/plone/plone.locking/commit/780f9b69316bf90891fd4ab8fc850f9d98969744 | ||
|
||
remove bbb adapter to access controlpanel registry data | ||
Register a fallback @@plone_lock_info view to allow objects without plone.locking behavior to be edited. | ||
|
||
Files changed: | ||
A news/104.bugfix | ||
M plone/app/users/browser/register.py | ||
A news/3331.fix | ||
A plone/locking/tests/test_views.py | ||
M plone/locking/browser/locking.py | ||
M plone/locking/configure.zcml | ||
|
||
b'diff --git a/news/104.bugfix b/news/104.bugfix\nnew file mode 100644\nindex 0000000..b060b88\n--- /dev/null\n+++ b/news/104.bugfix\n@@ -0,0 +1,3 @@\n+Use registry API to access usergroup settings. \n+Removes usages of deprecated API. \n+[jensens]\ndiff --git a/plone/app/users/browser/register.py b/plone/app/users/browser/register.py\nindex c4985db..ee767a9 100644\n--- a/plone/app/users/browser/register.py\n+++ b/plone/app/users/browser/register.py\n@@ -647,10 +647,8 @@ def updateFields(self):\n not settings.enable_user_pwd_choice\n \n # Append the manager-focused fields\n- user_group_settings = getAdapter(\n- aq_inner(self.context),\n- IUserGroupsSettingsSchema,\n- )\n+ registry = getUtility(IRegistry)\n+ user_group_settings = registry.forInterface(IUserGroupsSettingsSchema, prefix="plone")\n many_groups = user_group_settings.many_groups\n if not many_groups:\n allFields = defaultFields + field.Fields(IAddUserSchema)\n' | ||
b'diff --git a/news/3331.fix b/news/3331.fix\nnew file mode 100644\nindex 0000000..9efab5b\n--- /dev/null\n+++ b/news/3331.fix\n@@ -0,0 +1,2 @@\n+Register a fallback @@plone_lock_info view to allow objects without plone.locking behavior to be edited.\n+[ericof]\n\\ No newline at end of file\ndiff --git a/plone/locking/browser/locking.py b/plone/locking/browser/locking.py\nindex 7f4145e..6453bdc 100644\n--- a/plone/locking/browser/locking.py\n+++ b/plone/locking/browser/locking.py\n@@ -161,3 +161,23 @@ def _getNiceTimeDifference(self, baseTime):\n else:\n dateString = _(u"$d days and $h hours", mapping={\'d\': days, \'h\': hours})\n return dateString\n+\n+\n+class LockingInformationFallback(BrowserView):\n+ """Fallback view for Lock information.\n+\n+ This view exists to return sensible defaults if a content type does\n+ not have the plone.locking behavior active.\n+ """\n+\n+ def is_locked(self):\n+ return False\n+\n+ def is_locked_for_current_user(self):\n+ return False\n+\n+ def lock_is_stealable(self):\n+ return False\n+\n+ def lock_info(self):\n+ return None\ndiff --git a/plone/locking/configure.zcml b/plone/locking/configure.zcml\nindex c4890e2..9c8ed2c 100644\n--- a/plone/locking/configure.zcml\n+++ b/plone/locking/configure.zcml\n@@ -22,4 +22,12 @@\n allowed_attributes="is_locked is_locked_for_current_user lock_is_stealable lock_info"\n />\n \n+ <browser:page\n+ for="*"\n+ name="plone_lock_info"\n+ class=".browser.locking.LockingInformationFallback"\n+ permission="zope2.View"\n+ allowed_attributes="is_locked is_locked_for_current_user lock_is_stealable lock_info"\n+ />\n+\n </configure>\ndiff --git a/plone/locking/tests/test_views.py b/plone/locking/tests/test_views.py\nnew file mode 100644\nindex 0000000..412c3b0\n--- /dev/null\n+++ b/plone/locking/tests/test_views.py\n@@ -0,0 +1,44 @@\n+# -*- coding: utf-8 -*-\n+from plone.app.testing import setRoles\n+from plone.app.testing import TEST_USER_ID\n+from plone.locking.browser.locking import LockingInformation\n+from plone.locking.browser.locking import LockingInformationFallback\n+from plone.locking.testing import PLONE_LOCKING_INTEGRATION_TESTING\n+from plone.dexterity.interfaces import IDexterityFTI\n+from zope.component import queryUtility\n+\n+import unittest\n+\n+\n+class TestLockInfoViewWithoutLocking(unittest.TestCase):\n+\n+ layer = PLONE_LOCKING_INTEGRATION_TESTING\n+\n+ view = "@@plone_lock_info"\n+\n+ def setUp(self):\n+ self.app = self.layer["app"]\n+ self.portal = self.layer["portal"]\n+\n+ setRoles(self.portal, TEST_USER_ID, ["Manager", "Site Administrator"])\n+\n+ self.portal.invokeFactory("News Item", id="news1", title="News Item 1")\n+ self.news = self.portal["news1"]\n+\n+ # Remove plone.locking from Document content type\n+ fti = queryUtility(IDexterityFTI, name="Document")\n+ behavior_list = [a for a in fti.behaviors if a != "plone.locking"]\n+ fti.behaviors = tuple(behavior_list)\n+\n+ self.portal.invokeFactory("Document", id="doc1", title="Document 1")\n+ self.doc = self.portal["doc1"]\n+\n+ def test_browser_view_available_for_content_with_locking_behavior(self):\n+ content = self.news\n+ view = content.restrictedTraverse(self.view)\n+ self.assertIsInstance(view, LockingInformation)\n+\n+ def test_browser_view_available_for_content_without_locking_behavior(self):\n+ content = self.doc\n+ view = content.restrictedTraverse(self.view)\n+ self.assertIsInstance(view, LockingInformationFallback)\n' | ||
|
||
Repository: plone.app.users | ||
Repository: plone.locking | ||
|
||
|
||
Branch: refs/heads/master | ||
Date: 2021-10-08T12:37:11+02:00 | ||
Author: Johannes Raggam (thet) <thetetet@gmail.com> | ||
Commit: https://github.com/plone/plone.app.users/commit/7132145e3306a99a268f3683daab9d3afdac6f52 | ||
Date: 2021-10-08T23:33:43+02:00 | ||
Author: Maurits van Rees (mauritsvanrees) <m.van.rees@zestsoftware.nl> | ||
Commit: https://github.com/plone/plone.locking/commit/16f132198012601b9b433f346c0a81b19a26be5e | ||
|
||
Merge pull request #104 from plone/rm-bbb-controlpanel-adapter | ||
Merge pull request #18 from plone/issue-3331-removing-lock-behavior | ||
|
||
Remove bbb adapter to access controlpanel registry data | ||
Add fallback plone_lock_info view | ||
|
||
Files changed: | ||
A news/104.bugfix | ||
M plone/app/users/browser/register.py | ||
A news/3331.fix | ||
A plone/locking/tests/test_views.py | ||
M plone/locking/browser/locking.py | ||
M plone/locking/configure.zcml | ||
|
||
b'diff --git a/news/104.bugfix b/news/104.bugfix\nnew file mode 100644\nindex 0000000..b060b88\n--- /dev/null\n+++ b/news/104.bugfix\n@@ -0,0 +1,3 @@\n+Use registry API to access usergroup settings. \n+Removes usages of deprecated API. \n+[jensens]\ndiff --git a/plone/app/users/browser/register.py b/plone/app/users/browser/register.py\nindex c4985db..ee767a9 100644\n--- a/plone/app/users/browser/register.py\n+++ b/plone/app/users/browser/register.py\n@@ -647,10 +647,8 @@ def updateFields(self):\n not settings.enable_user_pwd_choice\n \n # Append the manager-focused fields\n- user_group_settings = getAdapter(\n- aq_inner(self.context),\n- IUserGroupsSettingsSchema,\n- )\n+ registry = getUtility(IRegistry)\n+ user_group_settings = registry.forInterface(IUserGroupsSettingsSchema, prefix="plone")\n many_groups = user_group_settings.many_groups\n if not many_groups:\n allFields = defaultFields + field.Fields(IAddUserSchema)\n' | ||
b'diff --git a/news/3331.fix b/news/3331.fix\nnew file mode 100644\nindex 0000000..9efab5b\n--- /dev/null\n+++ b/news/3331.fix\n@@ -0,0 +1,2 @@\n+Register a fallback @@plone_lock_info view to allow objects without plone.locking behavior to be edited.\n+[ericof]\n\\ No newline at end of file\ndiff --git a/plone/locking/browser/locking.py b/plone/locking/browser/locking.py\nindex 7f4145e..6453bdc 100644\n--- a/plone/locking/browser/locking.py\n+++ b/plone/locking/browser/locking.py\n@@ -161,3 +161,23 @@ def _getNiceTimeDifference(self, baseTime):\n else:\n dateString = _(u"$d days and $h hours", mapping={\'d\': days, \'h\': hours})\n return dateString\n+\n+\n+class LockingInformationFallback(BrowserView):\n+ """Fallback view for Lock information.\n+\n+ This view exists to return sensible defaults if a content type does\n+ not have the plone.locking behavior active.\n+ """\n+\n+ def is_locked(self):\n+ return False\n+\n+ def is_locked_for_current_user(self):\n+ return False\n+\n+ def lock_is_stealable(self):\n+ return False\n+\n+ def lock_info(self):\n+ return None\ndiff --git a/plone/locking/configure.zcml b/plone/locking/configure.zcml\nindex c4890e2..9c8ed2c 100644\n--- a/plone/locking/configure.zcml\n+++ b/plone/locking/configure.zcml\n@@ -22,4 +22,12 @@\n allowed_attributes="is_locked is_locked_for_current_user lock_is_stealable lock_info"\n />\n \n+ <browser:page\n+ for="*"\n+ name="plone_lock_info"\n+ class=".browser.locking.LockingInformationFallback"\n+ permission="zope2.View"\n+ allowed_attributes="is_locked is_locked_for_current_user lock_is_stealable lock_info"\n+ />\n+\n </configure>\ndiff --git a/plone/locking/tests/test_views.py b/plone/locking/tests/test_views.py\nnew file mode 100644\nindex 0000000..412c3b0\n--- /dev/null\n+++ b/plone/locking/tests/test_views.py\n@@ -0,0 +1,44 @@\n+# -*- coding: utf-8 -*-\n+from plone.app.testing import setRoles\n+from plone.app.testing import TEST_USER_ID\n+from plone.locking.browser.locking import LockingInformation\n+from plone.locking.browser.locking import LockingInformationFallback\n+from plone.locking.testing import PLONE_LOCKING_INTEGRATION_TESTING\n+from plone.dexterity.interfaces import IDexterityFTI\n+from zope.component import queryUtility\n+\n+import unittest\n+\n+\n+class TestLockInfoViewWithoutLocking(unittest.TestCase):\n+\n+ layer = PLONE_LOCKING_INTEGRATION_TESTING\n+\n+ view = "@@plone_lock_info"\n+\n+ def setUp(self):\n+ self.app = self.layer["app"]\n+ self.portal = self.layer["portal"]\n+\n+ setRoles(self.portal, TEST_USER_ID, ["Manager", "Site Administrator"])\n+\n+ self.portal.invokeFactory("News Item", id="news1", title="News Item 1")\n+ self.news = self.portal["news1"]\n+\n+ # Remove plone.locking from Document content type\n+ fti = queryUtility(IDexterityFTI, name="Document")\n+ behavior_list = [a for a in fti.behaviors if a != "plone.locking"]\n+ fti.behaviors = tuple(behavior_list)\n+\n+ self.portal.invokeFactory("Document", id="doc1", title="Document 1")\n+ self.doc = self.portal["doc1"]\n+\n+ def test_browser_view_available_for_content_with_locking_behavior(self):\n+ content = self.news\n+ view = content.restrictedTraverse(self.view)\n+ self.assertIsInstance(view, LockingInformation)\n+\n+ def test_browser_view_available_for_content_without_locking_behavior(self):\n+ content = self.doc\n+ view = content.restrictedTraverse(self.view)\n+ self.assertIsInstance(view, LockingInformationFallback)\n' | ||
|