From d365294db7edd79f01b51ac30413707a556f84bb Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Fri, 13 Oct 2023 13:13:28 -0400 Subject: Added pending comment page to admin panel --- app/controllers/admin/comments_controller.rb | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'app/controllers') diff --git a/app/controllers/admin/comments_controller.rb b/app/controllers/admin/comments_controller.rb index bd255ad..ccde3e6 100644 --- a/app/controllers/admin/comments_controller.rb +++ b/app/controllers/admin/comments_controller.rb @@ -2,7 +2,29 @@ class Admin::CommentsController < Admin::AdminController before_action :set_section def index - @comments = Comment.order(updated_at: :desc).paginate(page: params[:page], per_page: 20) + @comments = Comment.where(status: :published).order(updated_at: :desc).paginate(page: params[:page], per_page: 20) + end + + def pending + @comments = Comment.where(status: :pending).order(updated_at: :desc).paginate(page: params[:page], per_page: 20) + end + + def accept + @comment = Comment.find(params[:id]) + @comment.status = :published + @comment.save! + + flash.notice = "Comment successfully published." + redirect_to pending_admin_comments_url + end + + def reject + @comment = Comment.find(params[:id]) + @comment.status = :rejected + @comment.save! + + flash.notice = "Comment successfully rejected." + redirect_to pending_admin_comments_url end def destroy -- cgit 1.4.1