New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add search to @sharing #316
Conversation
@jaroel so the idea would be that you can query @sharing on the portal root instead of the @Principals endpoint, correct? FYI: Even though we are still in alpha, I would prefer to deprecate a method first, before finally removing it at a later version. People are already using plone.restapi in production. Unlike Google/Angular, we take breaking changes seriously. ;) |
docs/source/sharing.rst
Outdated
@@ -35,6 +35,9 @@ The sharing information of a content object can also be directly accessed by app | |||
.. literalinclude:: _json/sharing_folder_get.resp | |||
:language: http | |||
|
|||
.. note:: | |||
Searching for users and/or groups who do not yet have a sharing entry can be done by appending the argument `search_term` to the query string. ie search_term=admin |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jaroel I would prefer to use "search" instead of "search_term" to be consistent with the other endpoints.
@jaroel is it possible that you forgot to add the "@Principals" search implementation? Or would that be another pr? |
@tisto you'll use @sharing on context, so the results will include the correct acquired and inherited flags. @Principals never supported this and never will, unless it is called on context. |
@tiso I've reverted removing @Principals. Could you reviews this again? |
@sneridagh if you have time I would like to hear your opinion on that pull request. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR looks good to me and the feature is desirable. We need to discuss the issues I raised in the review though.
docs/source/sharing.rst
Outdated
@@ -35,6 +35,9 @@ The sharing information of a content object can also be directly accessed by app | |||
.. literalinclude:: _json/sharing_folder_get.resp | |||
:language: http | |||
|
|||
.. note:: | |||
Users and/or groups without a sharing entry can be found by appending the argument `search` to the query string. ie search=admin. It will also flag or global roles. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jaroel what does "It will also flag or global roles" mean?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, that's just stupid.
sharing_view = getMultiAdapter((self.context, self.request), | ||
name='sharing') | ||
local_roles = sharing_view.existing_role_settings() | ||
local_roles = sharing_view.role_settings() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jaroel this changes the structure of what we return on the sharing view, correct? If this is the case, this is a breaking change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope, it's just that the search results are also in 'entries'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. Fine with me then.
search_entries = response.json()['entries'] | ||
|
||
# Did we find anything? | ||
self.assertNotEqual(len(non_search_entries), len(search_entries)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jaroel could we add some more tests here to make it visible what the sharing search actually returns?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, no problem!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sneridagh That would be the same a normal post, wouldn't it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes it would. The idea is just to make sure that you can GET first, slightly manipulate the result and POST it back.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tisto / @sneridagh I've added a test for this
docs/source/sharing.rst
Outdated
@@ -35,6 +35,10 @@ The sharing information of a content object can also be directly accessed by app | |||
.. literalinclude:: _json/sharing_folder_get.resp | |||
:language: http | |||
|
|||
.. note:: | |||
Users and/or groups without a sharing entry can be found by appending the argument `search` to the query string. ie search=admin. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jaroel it would be nice to include a documentation example of the usage of the search term to test_documentation.py . I think it will be common enough use case to have it's own example.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tisto / @sneridagh I've added a test for this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would also not deprecate the @Principals endpoint, it could be handy for some other use cases.
Apart from the minor issues @sneridagh and I raised this PR looks good to me and can be merged. |
@sneridagh could you please have a second look at this pr and let me know if you are happy with it now? |
No description provided.