Update the destination category id when a user changes it

This commit is contained in:
Robin Ward
2018-03-23 11:12:22 -04:00
parent 6e4b8901ce
commit 38af67eb73
6 changed files with 60 additions and 2 deletions

View File

@ -11,6 +11,7 @@ class TopicsController < ApplicationController
:timings,
:destroy_timings,
:update,
:update_shared_draft,
:destroy,
:recover,
:status,
@ -236,6 +237,17 @@ class TopicsController < ApplicationController
render body: nil
end
def update_shared_draft
topic = Topic.find_by(id: params[:id])
guardian.ensure_can_edit!(topic)
guardian.ensure_can_create_shared_draft!
raise Discourse::NotFound unless topic.shared_draft.present?
SharedDraft.where(topic_id: topic.id).update_all(category_id: params[:category_id].to_i)
render json: success_json
end
def update
topic = Topic.find_by(id: params[:topic_id])
guardian.ensure_can_edit!(topic)