Commit ed4c7190 authored by Valery Sizov's avatar Valery Sizov

Fix importers with OCC

parent e0caed91
...@@ -3,19 +3,17 @@ class Import::BaseController < ApplicationController ...@@ -3,19 +3,17 @@ class Import::BaseController < ApplicationController
private private
def get_or_create_namespace def get_or_create_namespace
existing_namespace = Namespace.find_by_path_or_name(@target_namespace) begin
namespace = Group.create!(name: @target_namespace, path: @target_namespace, owner: current_user)
if existing_namespace namespace.add_owner(current_user)
if existing_namespace.owner == current_user rescue ActiveRecord::RecordNotUnique, ActiveRecord::RecordInvalid
namespace = existing_namespace namespace = Namespace.find_by_path_or_name(@target_namespace)
else unless namespace.owner == current_user
@already_been_taken = true @already_been_taken = true
return false return false
end end
else
namespace = Group.create(name: @target_namespace, path: @target_namespace, owner: current_user)
namespace.add_owner(current_user)
namespace
end end
namespace
end end
end end
class AddUniqueIndexToNamespace < ActiveRecord::Migration
def change
remove_index :namespaces, :name
remove_index :namespaces, :path
add_index :namespaces, :name, unique: true
add_index :namespaces, :path, unique: true
end
end
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
# #
# It's strongly recommended that you check this file into your version control system. # It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20150225065047) do ActiveRecord::Schema.define(version: 20150306023112) do
# These are extensions that must be enabled in order to support this database # These are extensions that must be enabled in order to support this database
enable_extension "plpgsql" enable_extension "plpgsql"
...@@ -242,9 +242,9 @@ ActiveRecord::Schema.define(version: 20150225065047) do ...@@ -242,9 +242,9 @@ ActiveRecord::Schema.define(version: 20150225065047) do
end end
add_index "namespaces", ["created_at", "id"], name: "index_namespaces_on_created_at_and_id", using: :btree add_index "namespaces", ["created_at", "id"], name: "index_namespaces_on_created_at_and_id", using: :btree
add_index "namespaces", ["name"], name: "index_namespaces_on_name", using: :btree add_index "namespaces", ["name"], name: "index_namespaces_on_name", unique: true, using: :btree
add_index "namespaces", ["owner_id"], name: "index_namespaces_on_owner_id", using: :btree add_index "namespaces", ["owner_id"], name: "index_namespaces_on_owner_id", using: :btree
add_index "namespaces", ["path"], name: "index_namespaces_on_path", using: :btree add_index "namespaces", ["path"], name: "index_namespaces_on_path", unique: true, using: :btree
add_index "namespaces", ["type"], name: "index_namespaces_on_type", using: :btree add_index "namespaces", ["type"], name: "index_namespaces_on_type", using: :btree
create_table "notes", force: true do |t| create_table "notes", force: true do |t|
...@@ -334,12 +334,12 @@ ActiveRecord::Schema.define(version: 20150225065047) do ...@@ -334,12 +334,12 @@ ActiveRecord::Schema.define(version: 20150225065047) do
t.string "import_url" t.string "import_url"
t.integer "visibility_level", default: 0, null: false t.integer "visibility_level", default: 0, null: false
t.boolean "archived", default: false, null: false t.boolean "archived", default: false, null: false
t.string "avatar"
t.string "import_status" t.string "import_status"
t.float "repository_size", default: 0.0 t.float "repository_size", default: 0.0
t.integer "star_count", default: 0, null: false t.integer "star_count", default: 0, null: false
t.string "import_type" t.string "import_type"
t.string "import_source" t.string "import_source"
t.string "avatar"
end end
add_index "projects", ["created_at", "id"], name: "index_projects_on_created_at_and_id", using: :btree add_index "projects", ["created_at", "id"], name: "index_projects_on_created_at_and_id", using: :btree
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment