diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/admin/comments_controller.rb | 24 | ||||
-rw-r--r-- | app/views/admin/comments/pending.haml | 25 | ||||
-rw-r--r-- | app/views/layouts/admin.html.haml | 2 |
3 files changed, 50 insertions, 1 deletions
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 | |||
2 | before_action :set_section | 2 | before_action :set_section |
3 | 3 | ||
4 | def index | 4 | def index |
5 | @comments = Comment.order(updated_at: :desc).paginate(page: params[:page], per_page: 20) | 5 | @comments = Comment.where(status: :published).order(updated_at: :desc).paginate(page: params[:page], per_page: 20) |
6 | end | ||
7 | |||
8 | def pending | ||
9 | @comments = Comment.where(status: :pending).order(updated_at: :desc).paginate(page: params[:page], per_page: 20) | ||
10 | end | ||
11 | |||
12 | def accept | ||
13 | @comment = Comment.find(params[:id]) | ||
14 | @comment.status = :published | ||
15 | @comment.save! | ||
16 | |||
17 | flash.notice = "Comment successfully published." | ||
18 | redirect_to pending_admin_comments_url | ||
19 | end | ||
20 | |||
21 | def reject | ||
22 | @comment = Comment.find(params[:id]) | ||
23 | @comment.status = :rejected | ||
24 | @comment.save! | ||
25 | |||
26 | flash.notice = "Comment successfully rejected." | ||
27 | redirect_to pending_admin_comments_url | ||
6 | end | 28 | end |
7 | 29 | ||
8 | def destroy | 30 | def destroy |
diff --git a/app/views/admin/comments/pending.haml b/app/views/admin/comments/pending.haml new file mode 100644 index 0000000..6abf371 --- /dev/null +++ b/app/views/admin/comments/pending.haml | |||
@@ -0,0 +1,25 @@ | |||
1 | - title "Pending Comments" | ||
2 | = will_paginate @comments | ||
3 | %table#entries | ||
4 | %tr | ||
5 | %th Text | ||
6 | %th Author | ||
7 | %th Blog post | ||
8 | %th Date updated | ||
9 | %th | ||
10 | - @comments.each do |comment| | ||
11 | %tr{ class: cycle("even", "odd") } | ||
12 | %td= comment.body | ||
13 | %td | ||
14 | %ul | ||
15 | %li= comment.username | ||
16 | %li= comment.email | ||
17 | - unless comment.website.empty? | ||
18 | %li= comment.website | ||
19 | %td= link_to comment.blog.title, comment.blog | ||
20 | %td= comment.published_at.strftime("%B %d, %Y, %l:%M%P") | ||
21 | %td | ||
22 | %ul.admin-actions | ||
23 | %li= link_to "Accept", accept_admin_comment_url(comment), method: :post, data: { confirm: "Are you sure you want to accept this comment?" } | ||
24 | %li= link_to "Reject", reject_admin_comment_url(comment), method: :post, data: { confirm: "Are you sure you want to reject this comment?" } | ||
25 | = will_paginate @comments | ||
diff --git a/app/views/layouts/admin.html.haml b/app/views/layouts/admin.html.haml index 0f54183..3949b5e 100644 --- a/app/views/layouts/admin.html.haml +++ b/app/views/layouts/admin.html.haml | |||
@@ -39,5 +39,7 @@ | |||
39 | %li.minor= link_to "New game", new_admin_game_url | 39 | %li.minor= link_to "New game", new_admin_game_url |
40 | %li{major_sidebar_attrs("comments")} | 40 | %li{major_sidebar_attrs("comments")} |
41 | = link_to "Comments", admin_comments_url, class: "major-link" | 41 | = link_to "Comments", admin_comments_url, class: "major-link" |
42 | %ul.minors | ||
43 | %li.minor= link_to "Pending", pending_admin_comments_url | ||
42 | #main | 44 | #main |
43 | = yield | 45 | = yield |