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:
@@ -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
|
||||
|
||||
36
app/views/moderation/comments/index.html.erb
Normal file
36
app/views/moderation/comments/index.html.erb
Normal 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 %>
|
||||
|
||||
Reference in New Issue
Block a user