gitlab-org--gitlab-foss/app/services/groups/create_service.rb
2016-03-20 21:04:07 +01:00

21 lines
506 B
Ruby

module Groups
class CreateService < Groups::BaseService
def initialize(user, params = {})
@current_user, @params = user, params.dup
end
def execute
@group = Group.new(params)
unless Gitlab::VisibilityLevel.allowed_for?(current_user, params[:visibility_level])
deny_visibility_level(@group)
return @group
end
@group.name = @group.path.dup unless @group.name
@group.save
@group.add_owner(current_user)
@group
end
end
end