about summary refs log tree commit diff stats
path: root/app/controllers/admin
diff options
context:
space:
mode:
authorStar Rauchenberger <fefferburbia@gmail.com>2023-10-21 13:24:24 -0400
committerStar Rauchenberger <fefferburbia@gmail.com>2023-10-21 13:24:24 -0400
commit0d50b1f18993827cb6862efeedea528b64fad164 (patch)
tree3e01bd704662742a8847bd281616e29f06249cfa /app/controllers/admin
parent35906f26e24467c52b6cf09346abe57444e5963a (diff)
downloadthoughts-0d50b1f18993827cb6862efeedea528b64fad164.tar.gz
thoughts-0d50b1f18993827cb6862efeedea528b64fad164.tar.bz2
thoughts-0d50b1f18993827cb6862efeedea528b64fad164.zip
Added quote moderation panel
Diffstat (limited to 'app/controllers/admin')
-rw-r--r--app/controllers/admin/quotes_controller.rb34
1 files changed, 34 insertions, 0 deletions
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 @@
1class Admin::QuotesController < Admin::AdminController
2 before_action :set_section
3
4 def index
5 @quotes = Quote.published.order(id: :desc).paginate(page: params[:page], per_page: 20)
6 end
7
8 def pending
9 @quotes = Quote.pending.order(id: :desc).paginate(page: params[:page], per_page: 20)
10 end
11
12 def accept
13 @quote = Quote.find(params[:id])
14 @quote.state = :published
15 @quote.save!
16
17 flash.notice = "Quote successfully accepted."
18 redirect_to pending_admin_quotes_url
19 end
20
21 def destroy
22 @quote = Quote.find(params[:id])
23 @quote.destroy!
24
25 flash.notice = "Quote successfully rejected."
26 redirect_to pending_admin_quotes_url
27 end
28
29 private
30
31 def set_section
32 @section = "quotes"
33 end
34end