BigW Consortium Gitlab

base_controller.rb 562 Bytes
Newer Older
1 2 3
class Import::BaseController < ApplicationController
  private

4
  def find_or_create_namespace(name, owner)
5 6
    return current_user.namespace if name == owner
    return current_user.namespace unless current_user.can_create_group?
7

8 9 10
    begin
      name = params[:target_namespace].presence || name
      namespace = Group.create!(name: name, path: name, owner: current_user)
Valery Sizov committed
11
      namespace.add_owner(current_user)
12
      namespace
Valery Sizov committed
13
    rescue ActiveRecord::RecordNotUnique, ActiveRecord::RecordInvalid
14
      Namespace.find_by_path_or_name(name)
15 16 17
    end
  end
end