Interface is wired up for Approving/Rejecting posts

This commit is contained in:
Robin Ward
2015-04-14 14:21:02 -04:00
parent 96d2c5069b
commit 0c233e4e25
20 changed files with 273 additions and 90 deletions

View File

@ -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

View File

@ -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