FIX: add support for sub-sub-categories in base_importer

Also delegates 'post_already_imported?' and 'user_already_imported?' to the base importer.
This commit is contained in:
Régis Hanol 2020-02-05 10:35:55 +01:00
parent 13d4b05963
commit 0843e3e6ce
1 changed files with 22 additions and 10 deletions

View File

@ -125,14 +125,21 @@ class ImportScripts::Base
raise NotImplementedError
end
%i{ post_id_from_imported_post_id
topic_lookup_from_imported_post_id
group_id_from_imported_group_id
find_group_by_import_id
user_id_from_imported_user_id
find_user_by_import_id
%i{
add_category
add_group
add_post
add_topic
add_user
category_id_from_imported_category_id
add_group add_user add_category add_topic add_post
find_group_by_import_id
find_user_by_import_id
group_id_from_imported_group_id
post_already_imported?
post_id_from_imported_post_id
topic_lookup_from_imported_post_id
user_already_imported?
user_id_from_imported_user_id
}.each do |method_name|
delegate method_name, to: :@lookup
end
@ -432,8 +439,13 @@ class ImportScripts::Base
end
def create_category(opts, import_id)
existing = Category.where("LOWER(name) = ?", opts[:name].downcase).first
return existing if existing && existing.parent_category.try(:id) == opts[:parent_category_id]
existing =
Category
.where(parent_category_id: opts[:parent_category_id])
.where("LOWER(name) = ?", opts[:name].downcase.strip)
.first
return existing if existing
post_create_action = opts.delete(:post_create_action)