Skip to content
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

Merged
merged 14 commits into from May 23, 2017
Merged

Add search to @sharing #316

merged 14 commits into from May 23, 2017

Conversation

jaroel
Copy link
Member

@jaroel jaroel commented Apr 18, 2017

No description provided.

@coveralls
Copy link

coveralls commented Apr 18, 2017

Coverage Status

Coverage decreased (-0.02%) to 96.231% when pulling 2239d0c on sharing into 3b2c9e9 on master.

@tisto tisto requested a review from sneridagh April 18, 2017 16:20
@tisto
Copy link
Sponsor Member

tisto commented Apr 18, 2017

@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. ;)

@@ -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
Copy link
Sponsor Member

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.

@tisto
Copy link
Sponsor Member

tisto commented Apr 18, 2017

@jaroel is it possible that you forgot to add the "@Principals" search implementation? Or would that be another pr?

@jaroel
Copy link
Member Author

jaroel commented Apr 19, 2017

@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.
Yeah, @Principals should be deprecated first.
I'll make it so that we can use "search" instead of "search_term".

@jaroel jaroel changed the title Replace @principals with @@sharing?search_term support Replace @principals with @@sharing?search support Apr 19, 2017
@coveralls
Copy link

coveralls commented Apr 19, 2017

Coverage Status

Coverage increased (+0.2%) to 96.482% when pulling 25a6c60 on sharing into 3b2c9e9 on master.

@coveralls
Copy link

coveralls commented Apr 19, 2017

Coverage Status

Coverage increased (+0.2%) to 96.482% when pulling 25a6c60 on sharing into 3b2c9e9 on master.

@jaroel jaroel changed the title Replace @principals with @@sharing?search support Add search to @sharing Apr 19, 2017
@coveralls
Copy link

coveralls commented Apr 19, 2017

Coverage Status

Coverage increased (+0.2%) to 96.482% when pulling 80fb01c on sharing into 3b2c9e9 on master.

@jaroel
Copy link
Member Author

jaroel commented Apr 19, 2017

@tiso I've reverted removing @Principals. Could you reviews this again?

@tisto
Copy link
Sponsor Member

tisto commented Apr 19, 2017

@sneridagh if you have time I would like to hear your opinion on that pull request.

Copy link
Sponsor Member

@tisto tisto left a 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.

@@ -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.
Copy link
Sponsor Member

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?

Copy link
Member Author

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()
Copy link
Sponsor Member

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.

Copy link
Member Author

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'

Copy link
Sponsor Member

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))
Copy link
Sponsor Member

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?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, no problem!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jaroel Can we have a test that verifies that a POST to @sharing can be fed using the result from a previous GET to the endpoint?

Copy link
Member Author

@jaroel jaroel Apr 24, 2017

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?

Copy link
Sponsor Member

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.

Copy link
Member Author

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

@coveralls
Copy link

coveralls commented Apr 22, 2017

Coverage Status

Coverage increased (+0.2%) to 96.482% when pulling 190503d on sharing into 3b2c9e9 on master.

@coveralls
Copy link

coveralls commented Apr 22, 2017

Coverage Status

Coverage increased (+0.001%) to 96.482% when pulling 767dfac on sharing into a94169f on master.

@@ -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.
Copy link
Member

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.

Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

Copy link
Member Author

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

Copy link
Member

@sneridagh sneridagh left a 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.

@tisto
Copy link
Sponsor Member

tisto commented May 7, 2017

Apart from the minor issues @sneridagh and I raised this PR looks good to me and can be merged.

@coveralls
Copy link

coveralls commented May 8, 2017

Coverage Status

Coverage increased (+0.001%) to 96.384% when pulling 6e9a743 on sharing into 2d37bc7 on master.

@tisto
Copy link
Sponsor Member

tisto commented May 19, 2017

@sneridagh could you please have a second look at this pr and let me know if you are happy with it now?

@tisto tisto merged commit 5b35970 into master May 23, 2017
@tisto tisto deleted the sharing branch May 23, 2017 07:25
@tisto tisto removed the in progress label May 23, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants