Skip to content

Commit

Permalink
Merge 376cf74 into 2d37bc7
Browse files Browse the repository at this point in the history
  • Loading branch information
jaroel authored May 8, 2017
2 parents 2d37bc7 + 376cf74 commit 1ba82fe
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 19 deletions.
5 changes: 4 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ New Features:
- Add batched listing of registry entries to @registry endpoint.
[jaroel]

Bugfixes:
- Remove 'disabled' from @sharing entries, as it is a Plone template hint.
It doesn't actually mean that the entry is disabled.
[jaroel]

1.0a14 (2017-05-02)
-------------------
Expand All @@ -24,7 +28,6 @@ Bugfixes:
delete permissions over the parent folder.
[sneridagh]


1.0a13 (2017-04-18)
-------------------

Expand Down
27 changes: 13 additions & 14 deletions docs/source/_json/sharing_folder_get.resp
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,24 @@ Content-Type: application/json

{
"available_roles": [
"Contributor",
"Editor",
"Reviewer",
"Contributor",
"Editor",
"Reviewer",
"Reader"
],
],
"entries": [
{
"disabled": false,
"id": "AuthenticatedUsers",
"login": null,
"id": "AuthenticatedUsers",
"login": null,
"roles": {
"Contributor": false,
"Editor": false,
"Reader": false,
"Contributor": false,
"Editor": false,
"Reader": false,
"Reviewer": false
},
"title": "Logged-in users",
},
"title": "Logged-in users",
"type": "group"
}
],
],
"inherit": false
}
}
12 changes: 11 additions & 1 deletion src/plone/restapi/serializer/local_roles.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,19 @@ def __call__(self):
sharing_view = getMultiAdapter((self.context, self.request),
name='sharing')
local_roles = sharing_view.existing_role_settings()

# We remove the disabled flag. The entry isn't disabled, but just used
# as a flag for the Plone template to prevent removing a users own
# entry.
entries = []
for role in local_roles:
if 'disabled' in role:
del role['disabled']
entries.append(role)

available_roles = [r['id'] for r in sharing_view.roles()]
return {'inherit': getattr(aq_base(self.context),
'__ac_local_roles_block__',
False),
'entries': local_roles,
'entries': entries,
'available_roles': available_roles}
15 changes: 12 additions & 3 deletions src/plone/restapi/tests/test_content_local_roles.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,18 @@ def _get_ac_local_roles_block(self, obj):
'__ac_local_roles_block__',
False))

def test_sharing_no_disabled(self):
'''A sharing response should not contain a disabled flag.
'''
response = requests.get(
self.portal.folder1.absolute_url() + '/@sharing?search=' + SITE_OWNER_NAME, # noqa
headers={'Accept': 'application/json'},
auth=(SITE_OWNER_NAME, SITE_OWNER_PASSWORD),
)
self.assertGreater(len(response.json()['entries']), 0)
for entry in response.json()['entries']:
self.assertNotIn('disabled', entry)

def test_sharing_requires_delegate_roles_permission(self):
'''A response for an object without any roles assigned'''
response = requests.get(
Expand All @@ -62,7 +74,6 @@ def test_get_local_roles_none_assigned(self):
response.json(),
{u'available_roles': [u'Contributor', u'Editor', u'Reviewer', u'Reader'], # noqa
u'entries': [{
u'disabled': False,
u'id': u'AuthenticatedUsers',
u'login': None,
u'roles': {u'Contributor': False,
Expand Down Expand Up @@ -92,7 +103,6 @@ def test_get_local_roles_with_user(self):
{u'available_roles': [u'Contributor', u'Editor', u'Reviewer', u'Reader'], # noqa
u'entries': [
{
u'disabled': False,
u'id': u'AuthenticatedUsers',
u'login': None,
u'roles': {u'Contributor': False,
Expand All @@ -102,7 +112,6 @@ def test_get_local_roles_with_user(self):
u'title': u'Logged-in users',
u'type': u'group'},
{
u'disabled': False,
u'id': u'test_user_1_',
u'roles': {u'Contributor': False,
u'Editor': False,
Expand Down

0 comments on commit 1ba82fe

Please sign in to comment.