mirror of
https://github.com/discourse/discourse.git
synced 2025-03-24 20:05:46 +08:00
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:
parent
13d4b05963
commit
0843e3e6ce
@ -125,14 +125,21 @@ class ImportScripts::Base
|
|||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
end
|
end
|
||||||
|
|
||||||
%i{ post_id_from_imported_post_id
|
%i{
|
||||||
topic_lookup_from_imported_post_id
|
add_category
|
||||||
group_id_from_imported_group_id
|
add_group
|
||||||
find_group_by_import_id
|
add_post
|
||||||
user_id_from_imported_user_id
|
add_topic
|
||||||
find_user_by_import_id
|
add_user
|
||||||
category_id_from_imported_category_id
|
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|
|
}.each do |method_name|
|
||||||
delegate method_name, to: :@lookup
|
delegate method_name, to: :@lookup
|
||||||
end
|
end
|
||||||
@ -432,8 +439,13 @@ class ImportScripts::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
def create_category(opts, import_id)
|
def create_category(opts, import_id)
|
||||||
existing = Category.where("LOWER(name) = ?", opts[:name].downcase).first
|
existing =
|
||||||
return existing if existing && existing.parent_category.try(:id) == opts[:parent_category_id]
|
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)
|
post_create_action = opts.delete(:post_create_action)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user