aboutsummaryrefslogtreecommitdiffstats
path: root/app/controllers/refinery/blog/admin/comments_controller.rb
blob: ce4ac70ca98111efdd7dc36cf0d578bdcc2277d7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
module Refinery
  module Blog
    module Admin
      class CommentsController < ::Refinery::AdminController

        cache_sweeper Refinery::BlogSweeper

        crudify :'refinery/blog/comment',
                :title_attribute => :name,
                :order => 'published_at DESC'

        def index
          @comments = Refinery::Blog::Comment.unmoderated.page(params[:page])

          render :index
        end

        def approved
          @comments = Refinery::Blog::Comment.approved.page(params[:page])

          render :index
        end

        def approve
          @comment = Refinery::Blog::Comment.find(params[:id])
          @comment.approve!
          flash[:notice] = t('approved', :scope => 'refinery.blog.admin.comments', :author => @comment.name)

          redirect_to refinery.blog_admin_comments_path
        end

        def rejected
          @comments = Refinery::Blog::Comment.rejected.page(params[:page])

          render :index
        end

        def reject
          @comment = Refinery::Blog::Comment.find(params[:id])
          @comment.reject!
          flash[:notice] = t('rejected', :scope => 'refinery.blog.admin.comments', :author => @comment.name)

          redirect_to refinery.blog_admin_comments_path
        end

      end
    end
  end
end