Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2016-12-26 12:56:19 +0300
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2016-12-26 12:56:19 +0300
commit9410f215eab0ba49051d2a00f0b4174f5dc13a6f (patch)
treea58709f8aac225b1fc9000ed868045ea54a4da5a /app/services/groups/create_service.rb
parent7b4b3d5f268534c028f55ef1014a84fe6a916cb0 (diff)
Add nested groups support to the Groups::CreateService
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'app/services/groups/create_service.rb')
-rw-r--r--app/services/groups/create_service.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/app/services/groups/create_service.rb b/app/services/groups/create_service.rb
index 2bccd584dde..9a630aee626 100644
--- a/app/services/groups/create_service.rb
+++ b/app/services/groups/create_service.rb
@@ -12,6 +12,19 @@ module Groups
return @group
end
+ parent_id = params[:parent_id]
+
+ if parent_id
+ parent = Group.find(parent_id)
+
+ unless can?(current_user, :admin_group, parent)
+ @group.parent_id = nil
+ @group.errors.add(:parent_id, 'manage access required to create subgroup')
+
+ return @group
+ end
+ end
+
@group.name ||= @group.path.dup
@group.save
@group.add_owner(current_user)