FEATURE: Option to export multiple categories using export_category method

This commit is contained in:
Vinoth Kanan
2017-11-11 18:52:22 +05:30
parent ed16cba77f
commit d9823f69c6
5 changed files with 38 additions and 22 deletions

View File

@ -4,10 +4,8 @@ require "import_export/topic_exporter"
module ImportExport
class CategoryExporter < BaseExporter
def initialize(category_id)
@category = Category.find(category_id)
@categories = Category.where(parent_category_id: category_id).to_a
@categories << @category
def initialize(category_ids)
@categories = Category.where(id: category_ids).or(Category.where(parent_category_id: category_ids)).to_a
@export_data = {
categories: [],
groups: [],
@ -17,7 +15,6 @@ module ImportExport
end
def perform
puts "Exporting category #{@category.name}...", ""
export_categories!
export_category_groups!
export_topics_and_users

View File

@ -11,12 +11,12 @@ module ImportExport
ImportExport::Importer.new(data).perform
end
def self.export_categories(include_users, filename = nil)
def self.export_category_structure(include_users, filename = nil)
ImportExport::CategoryStructureExporter.new(include_users).perform.save_to_file(filename)
end
def self.export_category(category_id, filename = nil)
ImportExport::CategoryExporter.new(category_id).perform.save_to_file(filename)
def self.export_categories(category_ids, filename = nil)
ImportExport::CategoryExporter.new(category_ids).perform.save_to_file(filename)
end
def self.export_topics(topic_ids, filename = nil)