-
-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Shows the can_delete key in the users and groups serializer only if the
user has "Plone Site Setup: Users and Groups" permission
- Loading branch information
Showing
7 changed files
with
79 additions
and
12 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
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
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
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
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 |
---|---|---|
|
@@ -3,7 +3,6 @@ Content-Type: application/json | |
|
||
{ | ||
"@id": "http://localhost:55001/plone/@users/noam", | ||
"can_delete": true, | ||
"description": "Professor of Linguistics", | ||
"email": "[email protected]", | ||
"fullname": "Noam Avram Chomsky", | ||
|
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,4 +1,5 @@ | ||
from plone import api | ||
from plone.app.testing import setRoles | ||
from plone.app.testing import TEST_USER_ID | ||
from plone.restapi.interfaces import ISerializeToJson | ||
from plone.restapi.interfaces import ISerializeToJsonSummary | ||
|
@@ -58,3 +59,24 @@ def test_summary(self): | |
self.assertEqual("Plone Team", group.get("title")) | ||
self.assertEqual("We are Plone", group.get("description")) | ||
self.assertNotIn("users", group) | ||
|
||
def test_serialize_group_with_member(self): | ||
setRoles(self.portal, TEST_USER_ID, ["Member"]) | ||
group = self.serialize(self.group) | ||
self.assertEqual( | ||
{ | ||
"@id": "http://nohost/plone/@groups/ploneteam", | ||
"id": "ploneteam", | ||
"groupname": "ploneteam", | ||
"email": "[email protected]", | ||
"title": "Plone Team", | ||
"description": "We are Plone", | ||
"roles": ["Authenticated"], | ||
"members": { | ||
"@id": "http://nohost", | ||
"items_total": 1, | ||
"items": ["test_user_1_"], | ||
}, | ||
}, | ||
group, | ||
) |
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,5 +1,7 @@ | ||
from DateTime import DateTime | ||
from plone import api | ||
from plone.app.testing import setRoles | ||
from plone.app.testing import TEST_USER_ID | ||
from plone.app.users.browser.schemaeditor import applySchema | ||
from plone.restapi.interfaces import ISerializeToJson | ||
from plone.restapi.testing import PLONE_RESTAPI_DX_INTEGRATION_TESTING | ||
|
@@ -49,7 +51,6 @@ def test_serialize_roles(self): | |
self.assertNotIn("Anonymous", user["roles"]) | ||
|
||
def test_serialize_custom_member_schema(self): | ||
from plone.app.users.browser.schemaeditor import applySchema | ||
|
||
member_schema = """ | ||
<model xmlns="http://namespaces.plone.org/supermodel/schema" | ||
|
@@ -79,6 +80,32 @@ def test_serialize_custom_member_schema(self): | |
self.assertIn("twitter", res) | ||
self.assertEqual(res["twitter"], "TheRealDuck") | ||
|
||
def test_serialize_user_with_member(self): | ||
setRoles(self.portal, TEST_USER_ID, ["Member"]) | ||
user = self.serialize(self.user) | ||
self.assertEqual( | ||
{ | ||
"@id": "http://nohost/plone/@users/noam", | ||
"id": "noam", | ||
"username": "noam", | ||
"roles": ["Member"], | ||
"fullname": "Noam Avram Chomsky", | ||
"email": "[email protected]", | ||
"home_page": "web.mit.edu/chomsky", | ||
"description": "Professor of Linguistics", | ||
"location": "Cambridge, MA", | ||
"portrait": None, | ||
"groups": { | ||
"@id": "http://nohost", | ||
"items_total": 1, | ||
"items": [ | ||
{"id": "AuthenticatedUsers", "title": "AuthenticatedUsers"} | ||
], | ||
}, | ||
}, | ||
user, | ||
) | ||
|
||
|
||
class TestSerializeUserCustomSchemaToJsonAdapter(unittest.TestCase): | ||
|
||
|