debian-mirror-gitlab/app/controllers/groups/children_controller.rb

43 lines
1.2 KiB
Ruby
Raw Normal View History

2018-12-05 23:21:45 +05:30
# frozen_string_literal: true
2018-03-17 18:26:18 +05:30
module Groups
class ChildrenController < Groups::ApplicationController
before_action :group
2018-03-27 19:54:05 +05:30
skip_cross_project_access_check :index
2018-03-17 18:26:18 +05:30
def index
parent = if params[:parent_id].present?
GroupFinder.new(current_user).execute(id: params[:parent_id])
else
@group
end
if parent.nil?
render_404
return
end
setup_children(parent)
respond_to do |format|
format.json do
serializer = GroupChildSerializer
.new(current_user: current_user)
.with_pagination(request, response)
serializer.expand_hierarchy(parent) if params[:filter].present?
render json: serializer.represent(@children)
end
end
end
protected
def setup_children(parent)
@children = GroupDescendantsFinder.new(current_user: current_user,
parent_group: parent,
2019-03-02 22:35:43 +05:30
params: params.to_unsafe_h).execute
2018-03-17 18:26:18 +05:30
@children = @children.page(params[:page])
end
end
end