Class: Gluttonberg::Admin::Content::CommentsController

Inherits:
BaseController
  • Object
show all
Includes:
ActionView::Helpers::TextHelper
Defined in:
app/controllers/gluttonberg/admin/content/comments_controller.rb

Instance Method Summary collapse

Instance Method Details

#deleteObject



19
20
21
22
23
24
25
26
27
# File 'app/controllers/gluttonberg/admin/content/comments_controller.rb', line 19

def delete
  @comment = Comment.find(params[:id], :conditions => {:commentable_type => "Gluttonberg::Article", :commentable_id => @article.id})
  display_delete_confirmation(
    :title      => "Delete Comment ?",
    :url        => admin_blog_article_comment_path(@blog, @article, @comment),
    :return_url => admin_blog_article_comments_path(@blog, @article), 
    :warning    => ""
  )
end

#destroyObject



37
38
39
40
41
42
43
44
45
46
47
# File 'app/controllers/gluttonberg/admin/content/comments_controller.rb', line 37

def destroy
  @comment = Comment.find(params[:id])
  if @comment.delete
    flash[:notice] = "The comment was successfully deleted."
    Gluttonberg::Feed.log(current_user,@comment, truncate(@comment.body, :length => 100) , "deleted")
    redirect_to admin_blog_article_comments_path(@blog, @article)
  else
    flash[:error] = "There was an error deleting the comment."
    redirect_to admin_blog_article_comments_path(@blog, @article)
  end
end

#indexObject



14
15
16
17
# File 'app/controllers/gluttonberg/admin/content/comments_controller.rb', line 14

def index
  find_article([:comments])
  @comments = @article.comments.paginate(:per_page => Gluttonberg::Setting.get_setting("number_of_per_page_items"), :page => params[:page])
end

#moderationObject



29
30
31
32
33
34
35
# File 'app/controllers/gluttonberg/admin/content/comments_controller.rb', line 29

def moderation 
  authorize_user_for_moderation
  @comment = Comment.find(params[:id], :conditions => {:commentable_type => "Gluttonberg::Article", :commentable_id => @article.id})
  @comment.moderate(params[:moderation])
  Gluttonberg::Feed.log(current_user,@comment, truncate(@comment.body, :length => 100) , params[:moderation])
  redirect_to admin_blog_article_comments_path(@blog, @article)
end