diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-06-21 15:08:35 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-06-21 15:08:35 +0300 |
commit | cd6e1ccea48e770d74296f4fdb8957d3cfb073f3 (patch) | |
tree | 36342527e2d281fc1ce52709c31b2ee9190f7685 /app/finders | |
parent | 29bc2e44c530aa7c534a5ca5720012e17863f33f (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/finders')
-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 |