mirror of
https://github.com/discourse/discourse.git
synced 2025-06-01 03:45:06 +08:00
Interface is wired up for Approving/Rejecting posts
This commit is contained in:
@ -219,6 +219,7 @@ class ApplicationController < ActionController::Base
|
||||
|
||||
def render_json_dump(obj, opts=nil)
|
||||
opts ||= {}
|
||||
obj['__rest_serializer'] = "1" if opts[:rest_serializer]
|
||||
render json: MultiJson.dump(obj), status: opts[:status] || 200
|
||||
end
|
||||
|
||||
|
@ -8,12 +8,20 @@ class QueuedPostsController < ApplicationController
|
||||
state = QueuedPost.states[(params[:state] || 'new').to_sym]
|
||||
state ||= QueuedPost.states[:new]
|
||||
|
||||
@queued_posts = QueuedPost.where(state: state)
|
||||
render_serialized(@queued_posts, QueuedPostSerializer, root: :queued_posts)
|
||||
@queued_posts = QueuedPost.where(state: state).includes(:topic, :user)
|
||||
render_serialized(@queued_posts, QueuedPostSerializer, root: :queued_posts, rest_serializer: true)
|
||||
end
|
||||
|
||||
def update
|
||||
qp = QueuedPost.where(id: params[:id]).first
|
||||
|
||||
state = params[:queued_post][:state]
|
||||
if state == 'approved'
|
||||
qp.approve!(current_user)
|
||||
elsif state == 'rejected'
|
||||
qp.reject!(current_user)
|
||||
end
|
||||
|
||||
render_serialized(qp, QueuedPostSerializer, root: :queued_posts)
|
||||
end
|
||||
|
||||
|
Reference in New Issue
Block a user