diff options
author | Valery Sizov <vsv2711@gmail.com> | 2015-03-06 17:39:20 +0300 |
---|---|---|
committer | Valery Sizov <vsv2711@gmail.com> | 2015-03-10 13:23:11 +0300 |
commit | ed4c7190ed47f0311ba5f5a140b2c71a694b05db (patch) | |
tree | e963827cb3d42964f33a02b5975c229fb28a8445 /app/controllers/import | |
parent | e0caed91e2cd6b959f808139df7c40f3644f88fd (diff) |
Fix importers with OCC
Diffstat (limited to 'app/controllers/import')
-rw-r--r-- | app/controllers/import/base_controller.rb | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/app/controllers/import/base_controller.rb b/app/controllers/import/base_controller.rb index 7dc0cac8d4c..edb8bd4160b 100644 --- a/app/controllers/import/base_controller.rb +++ b/app/controllers/import/base_controller.rb @@ -3,19 +3,17 @@ class Import::BaseController < ApplicationController private def get_or_create_namespace - existing_namespace = Namespace.find_by_path_or_name(@target_namespace) - - if existing_namespace - if existing_namespace.owner == current_user - namespace = existing_namespace - else + 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 - else - namespace = Group.create(name: @target_namespace, path: @target_namespace, owner: current_user) - namespace.add_owner(current_user) - namespace end + + namespace end end |