diff options
Diffstat (limited to 'app/finders/groups_finder.rb')
-rw-r--r-- | app/finders/groups_finder.rb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/app/finders/groups_finder.rb b/app/finders/groups_finder.rb index 074eb9add0f..9cc27a3096d 100644 --- a/app/finders/groups_finder.rb +++ b/app/finders/groups_finder.rb @@ -17,6 +17,7 @@ # include_parent_descendants: boolean (defaults to false) - includes descendant groups when # filtering by parent. The parent param must be present. # include_ancestors: boolean (defaults to true) +# organization: Scope the groups to the Organizations::Organization # # Users with full private access can see all groups. The `owned` and `parent` # params can be used to restrict the groups that are returned. @@ -44,6 +45,7 @@ class GroupsFinder < UnionFinder attr_reader :current_user, :params def filter_groups(groups) + groups = by_organization(groups) groups = by_parent(groups) groups = by_custom_attributes(groups) groups = filter_group_ids(groups) @@ -93,6 +95,13 @@ class GroupsFinder < UnionFinder groups.id_in(params[:filter_group_ids]) end + def by_organization(groups) + organization = params[:organization] + return groups unless organization + + groups.in_organization(organization) + end + # rubocop: disable CodeReuse/ActiveRecord def by_parent(groups) return groups unless params[:parent] |