Adds first version of comment moderation

Missing:
* Ensure removing a flag updates the flagged_at attribute correctly
* Showing the debate when the comment is not a “root”
* Filter (pending / reviewed / all)
* Order
* Same for debates
This commit is contained in:
kikito
2015-08-21 22:01:47 +02:00
parent b7718a2e5d
commit 00b51bbc23
3 changed files with 153 additions and 41 deletions

View File

@@ -1,8 +1,31 @@
class Moderation::CommentsController < Moderation::BaseController
before_filter :load_comments, only: :index
load_and_authorize_resource
def index
@comments = @comments.page(params[:page])
end
def hide
@comment = Comment.find(params[:id])
@comment.hide
end
end
def hide_in_moderation_screen
@comment.hide
redirect_to action: :index
end
def mark_as_reviewed
@comment.mark_as_reviewed
redirect_to action: :index
end
private
def load_comments
@comments = Comment.accessible_by(current_ability, :hide).where('inappropiate_flags_count > 0').includes(:commentable)
end
end