Handle membership in ProjectFinder

The ProjectFinder supports the `non_public` parameter. This can be used to find
only projects the user is member of.
This commit is contained in:
Toon Claes
2017-05-23 15:48:13 +02:00
parent 4fda13b68e
commit 07fc79e7c5
2 changed files with 4 additions and 5 deletions

View File

@ -257,10 +257,6 @@ module API
# project helpers
def filter_projects(projects)
if params[:membership]
projects = projects.merge(current_user.authorized_projects)
end
if params[:owned]
projects = projects.merge(current_user.owned_projects)
end

View File

@ -68,7 +68,10 @@ module API
end
def present_projects(options = {})
projects = ProjectsFinder.new(current_user: current_user).execute
finder_params = {}
finder_params[:non_public] = true if params[:membership].present?
projects = ProjectsFinder.new(current_user: current_user, params: finder_params).execute
projects = filter_projects(projects)
projects = projects.with_statistics if params[:statistics]
projects = projects.with_issues_enabled if params[:with_issues_enabled]