diff options
author | Douwe Maan <douwe@selenight.nl> | 2017-06-07 20:22:34 -0500 |
---|---|---|
committer | Douwe Maan <douwe@selenight.nl> | 2017-06-07 20:22:34 -0500 |
commit | e56556e1feadefe795c48b91b484ed04e022cf9b (patch) | |
tree | 6bbee7c8e3ca6e3eed4fa10408e5ee49fe40efda /app/controllers/dashboard | |
parent | 3ec37e2622f6729300a988c8f58dfb6c2aecb996 (diff) | |
download | gitlab-ce-e56556e1feadefe795c48b91b484ed04e022cf9b.tar.gz |
Use group and project finders instead of direct ActiveRecord relations
Diffstat (limited to 'app/controllers/dashboard')
-rw-r--r-- | app/controllers/dashboard/groups_controller.rb | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/app/controllers/dashboard/groups_controller.rb b/app/controllers/dashboard/groups_controller.rb index b339344dd40..742157d113d 100644 --- a/app/controllers/dashboard/groups_controller.rb +++ b/app/controllers/dashboard/groups_controller.rb @@ -1,16 +1,17 @@ class Dashboard::GroupsController < Dashboard::ApplicationController def index - @groups = if params[:parent_id] - parent = Group.find(params[:parent_id]) + @groups = + if params[:parent_id] && Group.supports_nested_groups? + parent = Group.find_by(id: params[:parent_id]) - if parent.users_with_parents.find_by(id: current_user) - Group.where(id: parent.children) - else - Group.none - end - else - Group.joins(:group_members).merge(current_user.group_members) - end + if can?(current_user, :read_group, parent) + GroupsFinder.new(current_user, parent: parent).execute + else + Group.none + end + else + current_user.groups + end @groups = @groups.search(params[:filter_groups]) if params[:filter_groups].present? @groups = @groups.includes(:route) |