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

View File

@@ -0,0 +1,36 @@
<h2><%= t('moderation.comments.index.title') %></h2>
<h3><%= page_entries_info @comments %></h3>
<table>
<tr>
<th><%= t('moderation.comments.index.flags') %></th>
<th><%= t('moderation.comments.index.debate') %></th>
<th><%= t('moderation.comments.index.comment') %></th>
<th><%= t('moderation.comments.index.updated_at') %></th>
</tr>
<% @comments.each do |comment| %>
<tr id="comment_<%= comment.id %>">
<td><%= comment.inappropiate_flags_count %></td>
<td><%= link_to(comment.debate.title, comment.debate) %></td>
<td><%= comment.body %></td>
<td><%= l comment.updated_at.to_date %></td>
<td>
<%= link_to t('moderation.comments.index.hide'), hide_in_moderation_screen_moderation_comment_path(comment), method: :put %>
</td>
<% if can? :mark_as_reviewed, comment %>
<td>
<%= link_to t('moderation.comments.index.mark_as_reviewed'), mark_as_reviewed_moderation_comment_path(comment), method: :put %>
</td>
<% end %>
<% if comment.reviewed? %>
<td>
<%= t('moderation.comments.index.reviewed') %>
</td>
<% end %>
</tr>
<% end %>
</table>
<%= paginate @comments %>