match the create api with the update api ... so api is more consistent

This commit is contained in:
Sam 2013-03-26 23:49:23 -07:00
parent 994ab94107
commit fc94d3e551
1 changed files with 17 additions and 0 deletions

View File

@ -40,11 +40,28 @@ class PostsController < ApplicationController
post.image_sizes = params[:image_sizes] if params[:image_sizes].present?
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)
if revisor.revise!(current_user, params[:post][:raw])
TopicLink.extract_from(post)
end
if post.errors.present?
render_json_error(post)
return