diff options
author | Valery Sizov <valery@gitlab.com> | 2015-11-05 12:38:00 +0200 |
---|---|---|
committer | Valery Sizov <valery@gitlab.com> | 2015-11-05 13:18:51 +0200 |
commit | 6051c28fc03b4d9928ee2f2855f210845f9c0579 (patch) | |
tree | 43447b26e57d81765f983ef38e34eb5b3ba10997 /app/finders | |
parent | 363900a3e7902cbda8f62b55eb2c30881b3dae3f (diff) | |
download | gitlab-ce-6051c28fc03b4d9928ee2f2855f210845f9c0579.tar.gz |
Allow groups to appear in the search results if the group owner allows it
Diffstat (limited to 'app/finders')
-rw-r--r-- | app/finders/groups_finder.rb | 57 |
1 files changed, 29 insertions, 28 deletions
diff --git a/app/finders/groups_finder.rb b/app/finders/groups_finder.rb index d3597ef0901..b5f3176461c 100644 --- a/app/finders/groups_finder.rb +++ b/app/finders/groups_finder.rb @@ -6,33 +6,34 @@ class GroupsFinder private def all_groups(current_user) - if current_user - if current_user.authorized_groups.any? - # User has access to groups - # - # Return only: - # groups with public projects - # groups with internal projects - # groups with joined projects - # - group_ids = Project.public_and_internal_only.pluck(:namespace_id) + - current_user.authorized_groups.pluck(:id) - Group.where(id: group_ids) - else - # User has no group membership - # - # Return only: - # groups with public projects - # groups with internal projects - # - Group.where(id: Project.public_and_internal_only.pluck(:namespace_id)) - end - else - # Not authenticated - # - # Return only: - # groups with public projects - Group.where(id: Project.public_only.pluck(:namespace_id)) - end + group_ids = if current_user + if current_user.authorized_groups.any? + # User has access to groups + # + # Return only: + # groups with public projects + # groups with internal projects + # groups with joined projects + # + Project.public_and_internal_only.pluck(:namespace_id) + + current_user.authorized_groups.pluck(:id) + else + # User has no group membership + # + # Return only: + # groups with public projects + # groups with internal projects + # + Project.public_and_internal_only.pluck(:namespace_id) + end + else + # Not authenticated + # + # Return only: + # groups with public projects + Project.public_only.pluck(:namespace_id) + end + + Group.where("public IS TRUE OR id IN(?)", group_ids) end end |