BigW Consortium Gitlab

base_controller.rb 545 Bytes
Newer Older
1 2 3 4 5
class Import::BaseController < ApplicationController

  private

  def get_or_create_namespace
Valery Sizov committed
6 7 8 9 10
    begin
      namespace = Group.create!(name: @target_namespace, path: @target_namespace, owner: current_user)
      namespace.add_owner(current_user)
    rescue ActiveRecord::RecordNotUnique, ActiveRecord::RecordInvalid
      namespace = Namespace.find_by_path_or_name(@target_namespace)
11
      unless current_user.can?(:create_projects, namespace)
12 13 14 15
        @already_been_taken = true
        return false
      end
    end
Valery Sizov committed
16 17

    namespace
18 19
  end
end