FEATURE: Allow admin to change timestamp of topic.

This commit is contained in:
Guo Xiang Tan
2015-07-26 00:06:49 +08:00
parent 90388aa18e
commit c7a21b7c23
11 changed files with 257 additions and 0 deletions

View File

@ -24,6 +24,7 @@ class TopicsController < ApplicationController
:bulk,
:reset_new,
:change_post_owners,
:change_timestamps,
:bookmark,
:unsubscribe]
@ -375,6 +376,22 @@ class TopicsController < ApplicationController
end
end
def change_timestamps
params.require(:topic_id)
params.require(:timestamp)
guardian.ensure_can_change_post_owner!
begin
PostTimestampChanger.new( topic_id: params[:topic_id].to_i,
timestamp: params[:timestamp].to_i ).change!
render json: success_json
rescue ActiveRecord::RecordInvalid
render json: failed_json, status: 422
end
end
def clear_pin
topic = Topic.find_by(id: params[:topic_id].to_i)
guardian.ensure_can_see!(topic)