discourse/app/controllers/queued_posts_controller.rb

29 lines
742 B
Ruby
Raw Normal View History

2015-04-10 17:00:50 -04:00
require_dependency 'queued_post_serializer'
class QueuedPostsController < ApplicationController
before_filter :ensure_staff
def index
state = QueuedPost.states[(params[:state] || 'new').to_sym]
state ||= QueuedPost.states[:new]
@queued_posts = QueuedPost.where(state: state).includes(:topic, :user)
render_serialized(@queued_posts, QueuedPostSerializer, root: :queued_posts, rest_serializer: true)
2015-04-10 17:00:50 -04:00
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
2015-04-10 17:00:50 -04:00
render_serialized(qp, QueuedPostSerializer, root: :queued_posts)
end
end