summaryrefslogtreecommitdiff
path: root/app/controllers/admin/topics_controller.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers/admin/topics_controller.rb')
-rw-r--r--app/controllers/admin/topics_controller.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/app/controllers/admin/topics_controller.rb b/app/controllers/admin/topics_controller.rb
index b451928e591..69bcfdf4791 100644
--- a/app/controllers/admin/topics_controller.rb
+++ b/app/controllers/admin/topics_controller.rb
@@ -45,6 +45,22 @@ class Admin::TopicsController < Admin::ApplicationController
notice: _('Topic %{topic_name} was successfully removed.') % { topic_name: @topic.title_or_name }
end
+ def merge
+ source_topic = Projects::Topic.find(merge_params[:source_topic_id])
+ target_topic = Projects::Topic.find(merge_params[:target_topic_id])
+
+ begin
+ ::Topics::MergeService.new(source_topic, target_topic).execute
+ rescue ArgumentError => e
+ return render status: :bad_request, json: { type: :alert, message: e.message }
+ end
+
+ message = _('Topic %{source_topic} was successfully merged into topic %{target_topic}.')
+ redirect_to admin_topics_path,
+ status: :found,
+ notice: message % { source_topic: source_topic.name, target_topic: target_topic.name }
+ end
+
private
def topic
@@ -63,4 +79,8 @@ class Admin::TopicsController < Admin::ApplicationController
:title
]
end
+
+ def merge_params
+ params.permit([:source_topic_id, :target_topic_id])
+ end
end