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.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/app/controllers/import/base_controller.rb b/app/controllers/import/base_controller.rb
new file mode 100644
index 00000000000..edb8bd4160b
--- /dev/null
+++ b/app/controllers/import/base_controller.rb
@@ -0,0 +1,19 @@
+class Import::BaseController < ApplicationController
+
+ private
+
+ def get_or_create_namespace
+ 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)
+ unless namespace.owner == current_user
+ @already_been_taken = true
+ return false
+ end
+ end
+
+ namespace
+ end
+end