summaryrefslogtreecommitdiff
path: root/app/controllers/import/base_controller.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers/import/base_controller.rb')
-rw-r--r--app/controllers/import/base_controller.rb6
1 files changed, 5 insertions, 1 deletions
diff --git a/app/controllers/import/base_controller.rb b/app/controllers/import/base_controller.rb
index 7e8597a5eb3..1ca33bc5d22 100644
--- a/app/controllers/import/base_controller.rb
+++ b/app/controllers/import/base_controller.rb
@@ -1,12 +1,16 @@
class Import::BaseController < ApplicationController
private
- def get_or_create_namespace
+ def find_or_create_namespace(name, owner)
begin
+ @target_namespace = params[:new_namespace].presence || name
+ @target_namespace = current_user.namespace_path if name == owner || !current_user.can_create_group?
+
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)
+
unless current_user.can?(:create_projects, namespace)
@already_been_taken = true
return false