diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2016-12-26 11:56:19 +0200 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2016-12-26 11:56:19 +0200 |
commit | 9410f215eab0ba49051d2a00f0b4174f5dc13a6f (patch) | |
tree | a58709f8aac225b1fc9000ed868045ea54a4da5a /app | |
parent | 7b4b3d5f268534c028f55ef1014a84fe6a916cb0 (diff) | |
download | gitlab-ce-9410f215eab0ba49051d2a00f0b4174f5dc13a6f.tar.gz |
Add nested groups support to the Groups::CreateService
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'app')
-rw-r--r-- | app/services/groups/create_service.rb | 13 |
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) |