From 0d50b1f18993827cb6862efeedea528b64fad164 Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Sat, 21 Oct 2023 13:24:24 -0400 Subject: Added quote moderation panel --- app/controllers/admin/quotes_controller.rb | 34 ++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 app/controllers/admin/quotes_controller.rb (limited to 'app/controllers') diff --git a/app/controllers/admin/quotes_controller.rb b/app/controllers/admin/quotes_controller.rb new file mode 100644 index 0000000..2c09627 --- /dev/null +++ b/app/controllers/admin/quotes_controller.rb @@ -0,0 +1,34 @@ +class Admin::QuotesController < Admin::AdminController + before_action :set_section + + def index + @quotes = Quote.published.order(id: :desc).paginate(page: params[:page], per_page: 20) + end + + def pending + @quotes = Quote.pending.order(id: :desc).paginate(page: params[:page], per_page: 20) + end + + def accept + @quote = Quote.find(params[:id]) + @quote.state = :published + @quote.save! + + flash.notice = "Quote successfully accepted." + redirect_to pending_admin_quotes_url + end + + def destroy + @quote = Quote.find(params[:id]) + @quote.destroy! + + flash.notice = "Quote successfully rejected." + redirect_to pending_admin_quotes_url + end + + private + + def set_section + @section = "quotes" + end +end -- cgit 1.4.1