diff options
author | Bob Van Landuyt <bob@vanlanduyt.co> | 2017-09-05 11:30:16 +0200 |
---|---|---|
committer | Bob Van Landuyt <bob@vanlanduyt.co> | 2017-10-04 22:46:49 +0200 |
commit | d33e15574b064e38ceadf8aafb47af985d1a7a7a (patch) | |
tree | 0852a044ceef545d7cdc5b17ee0ab70cee1f3e63 /app/controllers | |
parent | 376a8c66c1ca8ee2a95255d21c9d55ce006ab655 (diff) | |
download | gitlab-ce-d33e15574b064e38ceadf8aafb47af985d1a7a7a.tar.gz |
Add serializer for group children
Diffstat (limited to 'app/controllers')
-rw-r--r-- | app/controllers/groups_controller.rb | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb index b8def9f5812..17d40cedd5d 100644 --- a/app/controllers/groups_controller.rb +++ b/app/controllers/groups_controller.rb @@ -60,7 +60,22 @@ class GroupsController < Groups::ApplicationController end end + def children + parent = Group.find_by(parent_id: params[:parent_id]) || @group + if parent.nil? || !can?(current_user, :read_group, parent) + render_404 + end + + @children = GroupChildrenFinder.new(current_user, parent_group: parent, params: params).execute + respond_to do |format| + format.json do + render json: GroupChildrenSerializer + .new(current_user: current_user) + .with_pagination(request, response) + .represent(@children) + end + end end def activity |