match the create api with the update api ... so api is more consistent
This commit is contained in:
parent
994ab94107
commit
fc94d3e551
|
@ -40,11 +40,28 @@ class PostsController < ApplicationController
|
||||||
post.image_sizes = params[:image_sizes] if params[:image_sizes].present?
|
post.image_sizes = params[:image_sizes] if params[:image_sizes].present?
|
||||||
guardian.ensure_can_edit!(post)
|
guardian.ensure_can_edit!(post)
|
||||||
|
|
||||||
|
# to stay consistent with the create api,
|
||||||
|
# we should allow for title changes and category changes here
|
||||||
|
# we should also move all of this to a post updater.
|
||||||
|
if post.post_number == 1 && (params[:title] || params[:post][:category])
|
||||||
|
post.topic.title = params[:title] if params[:title]
|
||||||
|
Topic.transaction do
|
||||||
|
post.topic.change_category(params[:post][:category])
|
||||||
|
post.topic.save
|
||||||
|
end
|
||||||
|
|
||||||
|
if post.topic.errors.present?
|
||||||
|
render_json_error(post.topic)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
revisor = PostRevisor.new(post)
|
revisor = PostRevisor.new(post)
|
||||||
if revisor.revise!(current_user, params[:post][:raw])
|
if revisor.revise!(current_user, params[:post][:raw])
|
||||||
TopicLink.extract_from(post)
|
TopicLink.extract_from(post)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
if post.errors.present?
|
if post.errors.present?
|
||||||
render_json_error(post)
|
render_json_error(post)
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in New Issue