diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-07-20 18:40:28 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-07-20 18:40:28 +0300 |
commit | b595cb0c1dec83de5bdee18284abe86614bed33b (patch) | |
tree | 8c3d4540f193c5ff98019352f554e921b3a41a72 /app/finders/contributed_projects_finder.rb | |
parent | 2f9104a328fc8a4bddeaa4627b595166d24671d0 (diff) |
Add latest changes from gitlab-org/gitlab@15-2-stable-eev15.2.0-rc42
Diffstat (limited to 'app/finders/contributed_projects_finder.rb')
-rw-r--r-- | app/finders/contributed_projects_finder.rb | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/app/finders/contributed_projects_finder.rb b/app/finders/contributed_projects_finder.rb index a351d30229e..eccc7d3f2bb 100644 --- a/app/finders/contributed_projects_finder.rb +++ b/app/finders/contributed_projects_finder.rb @@ -11,12 +11,15 @@ class ContributedProjectsFinder < UnionFinder # current_user - When given the list of the projects is limited to those only # visible by this user. # + # ignore_visibility - When true the list of projects will include all contributed + # projects, regardless of their visibility to the current_user + # # Returns an ActiveRecord::Relation. - def execute(current_user = nil) + def execute(current_user = nil, ignore_visibility: false) # Do not show contributed projects if the user profile is private. return Project.none unless can_read_profile?(current_user) - segments = all_projects(current_user) + segments = all_projects(current_user, ignore_visibility) find_union(segments, Project).with_namespace.order_id_desc end @@ -27,7 +30,9 @@ class ContributedProjectsFinder < UnionFinder Ability.allowed?(current_user, :read_user_profile, @user) end - def all_projects(current_user) + def all_projects(current_user, ignore_visibility) + return [@user.contributed_projects] if ignore_visibility + projects = [] projects << @user.contributed_projects.visible_to_user(current_user) if current_user |