Experimental: Interface to Move Posts to an Existing Topic

This commit is contained in:
Robin Ward
2013-05-10 14:55:51 -04:00
parent f8e8538e19
commit cf01c98d81
24 changed files with 511 additions and 151 deletions
+9 -5
View File
@@ -127,18 +127,22 @@ class TopicsController < ApplicationController
end
def move_posts
requires_parameters(:title, :post_ids)
requires_parameters(:post_ids)
topic = Topic.where(id: params[:topic_id]).first
guardian.ensure_can_move_posts!(topic)
# Move the posts
new_topic = topic.move_posts(current_user, params[:title], params[:post_ids].map {|p| p.to_i})
args = {}
args[:title] = params[:title] if params[:title].present?
args[:destination_topic_id] = params[:destination_topic_id].to_i if params[:destination_topic_id].present?
if new_topic.present?
render json: {success: true, url: new_topic.relative_url}
dest_topic = topic.move_posts(current_user, params[:post_ids].map {|p| p.to_i}, args)
if dest_topic.present?
render json: {success: true, url: dest_topic.relative_url}
else
render json: {success: false}
end
end
def clear_pin