Index private review requests for search, and limit their results.
Review Request #7067 — Created March 16, 2015 and submitted
Previously, only publicly-accessible review requests were returned in the search results. Teams using private repositories or groups wouldn't get much benefit from our search support. Now, we index all the information needed with a review request to limit results based on the user's access. This works just like all our existing accessible_by functions. The index stores a private flag (indicating whether the review request is inaccessible in general to users), and then a series of IDs for invite-only groups, private repositories, and the list of users targeted for review. The search query is then constructed to compare the user's currently-accessible groups/repositories against the results of these lists. The search results shown are therefore personalized to the user's access. Unit tests were added for covering all the access control checks, along with some of the existing search functionality (general searches and filters). These tests are based on the equivalent tests for the review request accessibility filtering in the database.
Unit tests pass.
I created a bunch of review requests with the different combinations of
access-restricted objects (private repos, invite-only groups), with and
without my user having permission on those objects. I saw all the results
I expected.I tested this on local sites as well. I also got the results I expected.
Description | From | Last Updated |
---|---|---|
'RBSearchView' imported but unused |
reviewbot | |
local variable 'review_request' is assigned to but never used |
reviewbot | |
Col: 25 E131 continuation line unaligned for hanging indent |
reviewbot | |
Maybe reformat this a little using a variable? users = review_request.target_people.values_list('pk', flat=True) return list(users) or [0] |
david | |
We should make manager functions for these so they're not duplicated. |
david | |
'Q' imported but unused |
reviewbot |
- Change Summary:
-
Fixed some ReviewBot complaints.
- Commit:
-
d1695d526ce6c9c2fab98fbf322e4c4a0a5fc41edb85ba8751b95522f51f76c7138c6c6d6a52f94e
-
Tool: Pyflakes Processed Files: reviewboard/search/tests.py reviewboard/reviews/models/group.py reviewboard/reviews/models/review_request.py reviewboard/reviews/search_indexes.py reviewboard/reviews/managers.py reviewboard/search/views.py reviewboard/test.py Tool: PEP8 Style Checker Processed Files: reviewboard/search/tests.py reviewboard/reviews/models/group.py reviewboard/reviews/models/review_request.py reviewboard/reviews/search_indexes.py reviewboard/reviews/managers.py reviewboard/search/views.py reviewboard/test.py
- Change Summary:
-
- Split up an awkwardly-formatted line in the review request indexer.
- Added new
accessible_ids
functions toRepositoryManager
andReviewGroupManager
, which perform theaccessible()
request and return IDs of the matches. These are now used inReviewRequestManager.accessible
and the search view. We end up grabbing more IDs than we know we'll need for search, but it shouldn't really be a problem.
- Commit:
-
db85ba8751b95522f51f76c7138c6c6d6a52f94ec57f18372c2a6de80f60bf362e6f5898a7c4a21a
-
Tool: Pyflakes Processed Files: reviewboard/scmtools/managers.py reviewboard/search/tests.py reviewboard/reviews/models/group.py reviewboard/reviews/models/review_request.py reviewboard/reviews/search_indexes.py reviewboard/reviews/managers.py reviewboard/search/views.py reviewboard/test.py Tool: PEP8 Style Checker Processed Files: reviewboard/scmtools/managers.py reviewboard/search/tests.py reviewboard/reviews/models/group.py reviewboard/reviews/models/review_request.py reviewboard/reviews/search_indexes.py reviewboard/reviews/managers.py reviewboard/search/views.py reviewboard/test.py
-