-
-
Notifications
You must be signed in to change notification settings - Fork 76
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/main Date: 2025-01-27T08:48:48-08:00 Author: Mauro Amico (mamico) <[email protected]> Commit: plone/plone.restapi@3830080 AttributeError occurs in creator_name when the user is missing (#1867) * AttributeError occurs in creator_name when the user is missing * changelog * userid * Update news/1867.bugfix --------- Co-authored-by: David Glick <[email protected]> Files changed: A news/1867.bugfix M src/plone/restapi/services/locking/__init__.py M src/plone/restapi/tests/test_locking.py
- Loading branch information
Showing
1 changed file
with
21 additions
and
25 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,33 +1,29 @@ | ||
Repository: plonetheme.barceloneta | ||
Repository: plone.restapi | ||
|
||
|
||
Branch: refs/heads/master | ||
Date: 2025-01-27T15:15:46+01:00 | ||
Author: Peter Mathis (petschki) <[email protected]> | ||
Commit: https://github.com/plone/plonetheme.barceloneta/commit/5c71cafc9743e683ea1512b7bb5846464921c79f | ||
Branch: refs/heads/main | ||
Date: 2025-01-27T08:48:48-08:00 | ||
Author: Mauro Amico (mamico) <[email protected]> | ||
Commit: https://github.com/plone/plone.restapi/commit/3830080c59daf497880046022521ab8cdb10ee7a | ||
|
||
Preparing release 3.2.2 | ||
AttributeError occurs in creator_name when the user is missing (#1867) | ||
|
||
Files changed: | ||
M CHANGES.md | ||
M setup.py | ||
D news/389.internal | ||
D news/4090.bugfix | ||
|
||
b'diff --git a/CHANGES.md b/CHANGES.md\nindex 8cc709ef..80cc99a1 100644\n--- a/CHANGES.md\n+++ b/CHANGES.md\n@@ -9,6 +9,19 @@\n \n <!-- towncrier release notes start -->\n \n+## 3.2.2 (2025-01-27)\n+\n+\n+### Bug fixes:\n+\n+- Fix DeprecationWarnings. [maurits] #4090\n+\n+\n+### Internal:\n+\n+- TinyMCE = 7.6.1\n+ [petschki] #389\n+\n ## 3.2.1 (2024-12-17)\n \n \ndiff --git a/news/389.internal b/news/389.internal\ndeleted file mode 100644\nindex c41043ad..00000000\n--- a/news/389.internal\n+++ /dev/null\n@@ -1,2 +0,0 @@\n-TinyMCE = 7.6.1\n-[petschki]\ndiff --git a/news/4090.bugfix b/news/4090.bugfix\ndeleted file mode 100644\nindex 8528aefb..00000000\n--- a/news/4090.bugfix\n+++ /dev/null\n@@ -1 +0,0 @@\n-Fix DeprecationWarnings. [maurits]\ndiff --git a/setup.py b/setup.py\nindex b9d47ec8..73a5471f 100644\n--- a/setup.py\n+++ b/setup.py\n@@ -3,7 +3,7 @@\n from setuptools import setup\n \n \n-version = "3.2.2.dev0"\n+version = "3.2.2"\n \n long_description = f"{Path(\'README.md\').read_text()}\\n{Path(\'CHANGES.md\').read_text()}"\n \n' | ||
|
||
Repository: plonetheme.barceloneta | ||
|
||
|
||
Branch: refs/heads/master | ||
Date: 2025-01-27T15:16:27+01:00 | ||
Author: Peter Mathis (petschki) <[email protected]> | ||
Commit: https://github.com/plone/plonetheme.barceloneta/commit/bd5ead8f36dc6098f09587cd63bab9f4d6808faa | ||
|
||
Back to development: 3.2.3 | ||
* AttributeError occurs in creator_name when the user is missing | ||
|
||
* changelog | ||
|
||
* userid | ||
|
||
* Update news/1867.bugfix | ||
|
||
--------- | ||
|
||
Co-authored-by: David Glick <[email protected]> | ||
|
||
Files changed: | ||
M setup.py | ||
A news/1867.bugfix | ||
M src/plone/restapi/services/locking/__init__.py | ||
M src/plone/restapi/tests/test_locking.py | ||
|
||
b'diff --git a/setup.py b/setup.py\nindex 73a5471f..acc08ff9 100644\n--- a/setup.py\n+++ b/setup.py\n@@ -3,7 +3,7 @@\n from setuptools import setup\n \n \n-version = "3.2.2"\n+version = "3.2.3.dev0"\n \n long_description = f"{Path(\'README.md\').read_text()}\\n{Path(\'CHANGES.md\').read_text()}"\n \n' | ||
b'diff --git a/news/1867.bugfix b/news/1867.bugfix\nnew file mode 100644\nindex 000000000..f4ddcaac8\n--- /dev/null\n+++ b/news/1867.bugfix\n@@ -0,0 +1 @@\n+In the `@locking` endpoint, fixed edge cases where the user who owns the lock was not found correctly. @mamico\ndiff --git a/src/plone/restapi/services/locking/__init__.py b/src/plone/restapi/services/locking/__init__.py\nindex 1b22e975a..c9347a7b4 100644\n--- a/src/plone/restapi/services/locking/__init__.py\n+++ b/src/plone/restapi/services/locking/__init__.py\n@@ -7,14 +7,17 @@\n from plone.locking.interfaces import ILockable\n \n \n-def creator_name(username):\n- user = api.user.get(username=username)\n- return user.getProperty("fullname") or username\n+def creator_name(userid):\n+ user = api.user.get(userid=userid)\n+ if user:\n+ return user.getProperty("fullname") or userid\n+ else:\n+ return userid\n \n \n-def creator_url(username):\n+def creator_url(userid):\n url = api.portal.get().absolute_url()\n- return f"{url}/author/{username}"\n+ return f"{url}/author/{userid}"\n \n \n def creation_date(timestamp):\ndiff --git a/src/plone/restapi/tests/test_locking.py b/src/plone/restapi/tests/test_locking.py\nindex 191b4d6bd..40e7fc5b8 100644\n--- a/src/plone/restapi/tests/test_locking.py\n+++ b/src/plone/restapi/tests/test_locking.py\n@@ -1,3 +1,4 @@\n+from plone import api\n from plone.app.testing import login\n from plone.app.testing import SITE_OWNER_NAME\n from plone.app.testing import SITE_OWNER_PASSWORD\n@@ -112,3 +113,45 @@ def test_update_locked_object_with_token_succeeds(self):\n transaction.commit()\n self.assertEqual(response.status_code, 204)\n self.assertEqual(self.doc.Title(), "New Title")\n+\n+ def test_lock_user_removed(self):\n+ lockable = ILockable(self.doc)\n+ api.user.create(\n+ username="foo",\n+ email="[email protected]",\n+ roles=["Manager"],\n+ )\n+ with api.env.adopt_user(username="foo"):\n+ lockable.lock()\n+ api.user.delete(username="foo")\n+ transaction.commit()\n+ # the user that locked the object is no longer present\n+ response = self.api_session.get("/@lock")\n+ self.assertEqual(response.status_code, 200)\n+ self.assertEqual(response.json()["creator"], "foo")\n+ self.assertEqual(response.json()["creator_name"], "foo")\n+ self.assertTrue(lockable.locked())\n+\n+ def test_lock_username_vs_userid(self):\n+ lockable = ILockable(self.doc)\n+ api.user.create(\n+ username="foo1234",\n+ email="[email protected]",\n+ roles=["Manager"],\n+ properties={"fullname": "Foo Bar"},\n+ )\n+ pas = api.portal.get_tool("acl_users")\n+ # generally the username and userid are the same...\n+ self.assertEqual(pas.getUserById("foo1234").getUserName(), "foo1234")\n+ # ...but we can change it\n+ pas.updateLoginName("foo1234", "foo")\n+ self.assertEqual(pas.getUserById("foo1234").getUserName(), "foo")\n+ with api.env.adopt_user(username="foo"):\n+ lockable.lock()\n+ transaction.commit()\n+ response = self.api_session.get("/@lock")\n+ self.assertEqual(response.status_code, 200)\n+ # here the userid\n+ self.assertEqual(response.json()["creator"], "foo1234")\n+ self.assertEqual(response.json()["creator_name"], "Foo Bar")\n+ self.assertTrue(lockable.locked())\n' | ||
|