2019-05-03 06:17:27 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-10-27 04:29:36 +08:00
|
|
|
require "import_export/base_exporter"
|
2016-01-26 02:37:43 +08:00
|
|
|
|
2017-10-27 04:29:36 +08:00
|
|
|
module ImportExport
|
|
|
|
class TopicExporter < ImportExport::BaseExporter
|
2016-01-26 02:37:43 +08:00
|
|
|
|
|
|
|
def initialize(topic_ids)
|
2017-10-27 04:29:36 +08:00
|
|
|
@topics = Topic.where(id: topic_ids).to_a
|
2016-01-26 02:37:43 +08:00
|
|
|
@export_data = {
|
2017-10-27 04:29:36 +08:00
|
|
|
topics: [],
|
|
|
|
users: []
|
2016-01-26 02:37:43 +08:00
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
def perform
|
2017-10-27 04:29:36 +08:00
|
|
|
export_topics!
|
|
|
|
export_topic_users!
|
2016-01-26 02:37:43 +08:00
|
|
|
# TODO: user actions
|
|
|
|
|
|
|
|
self
|
|
|
|
end
|
|
|
|
|
2017-10-27 04:29:36 +08:00
|
|
|
def default_filename_prefix
|
|
|
|
"topic-export"
|
2016-01-26 02:37:43 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|