class Admin::PostCommentsController < Admin::ApplicationController respond_to :html, :xml, :json belongs_to_spud_app :blog_posts before_filter :find_comment, :only => [:show, :edit, :update, :destroy, :approve, :spam] add_breadcrumb 'Blog Posts', :admin_posts_path add_breadcrumb 'Comments', :admin_post_comments_path def index @page_name = "Comments" if params[:post_id] @post_comments = SpudPostComment.where(:spud_post_id => params[:post_id]) else @post_comments = SpudPostComment end @post_comments = @post_comments.order('created_at desc').includes(:post).paginate(:page => params[:page], :per_page => 15) respond_with @post_comments end def show respond_with @post_comment end def edit respond_with @post_comment end def update end def create end def approve if Spud::Blog.enable_rakismet && @post_comment.spam @post_comment.ham! end @post_comment.spam = false @post_comment.approved = true @post_comment.save() redirect_to request.referer || admin_post_comments_path end def spam if Spud::Blog.enable_rakismet && !@post_comment.spam @post_comment.spam! end @post_comment.spam = true @post_comment.approved = false @post_comment.save() redirect_to request.referer || admin_post_comments_path end def destroy if !@post_comment.destroy flash[:error] = "Whoops! Something odd happened while trying to delete that comment. Thats not fun. please try again." end respond_with @post_comment, :location => request.referer || admin_post_comments_path end private def find_comment @post_comment = SpudPostComment.find(params[:id]) end end