Merge pull request #518 from AyuntamientoMadrid/moderating-comments

Moderating comments
This commit is contained in:
Enrique García
2015-09-17 17:14:07 +02:00
8 changed files with 35 additions and 7 deletions

View File

@@ -4,7 +4,7 @@ class Admin::CommentsController < Admin::BaseController
before_action :load_comment, only: [:confirm_hide, :restore]
def index
@comments = Comment.only_hidden.send(@current_filter).order(hidden_at: :desc).page(params[:page])
@comments = Comment.only_hidden.with_visible_author.send(@current_filter).order(hidden_at: :desc).page(params[:page])
end
def confirm_hide

View File

@@ -18,10 +18,9 @@ class Comment < ActiveRecord::Base
belongs_to :user, -> { with_hidden }
scope :recent, -> { order(id: :desc) }
scope :sort_for_moderation, -> { order(flags_count: :desc, updated_at: :desc) }
scope :for_render, -> { with_hidden.includes(user: :organization) }
scope :with_visible_author, -> { joins(:user).where("users.hidden_at IS NULL") }
after_create :call_after_commented

View File

@@ -9,8 +9,12 @@
<li id="<%= dom_id(comment) %>">
<div class="row">
<div class="small-12 medium-8 column">
<%= text_with_links comment.body %>
<%= link_to comment.commentable.title, comment.commentable %>
<%= text_with_links comment.body %><br>
<% if comment.commentable.hidden? %>
(<%= t("admin.comments.index.hidden_#{comment.commentable_type.downcase}") %>: <%= comment.commentable.title %>)
<% else %>
<%= link_to comment.commentable.title, comment.commentable %>
<% end %>
</div>
<div class="small-6 medium-4 column text-right">
<%= link_to t("admin.actions.restore"),

View File

@@ -108,6 +108,7 @@ ignore_unused:
- 'admin.proposals.index.filter*'
- 'admin.organizations.index.filter*'
- 'admin.users.index.filter*'
- 'admin.comments.index.hidden_*'
- 'moderation.comments.index.filter*'
- 'moderation.debates.index.filter*'
- 'moderation.proposals.index.filter*'

View File

@@ -3,6 +3,7 @@ en:
models:
comment: Comment
debate: Debate
proposal: Proposal
tag: Topic
user: User
vote: Vote

View File

@@ -59,6 +59,8 @@ en:
comments:
index:
title: Hidden comments
hidden_proposal: "Hidden proposal"
hidden_debate: "Hidden debate"
filter: Filter
filters:
all: All

View File

@@ -59,6 +59,8 @@ es:
comments:
index:
title: Comentarios ocultos
hidden_proposal: "Propuesta oculta"
hidden_debate: "Debate oculto"
filter: Filtro
filters:
all: Todos

View File

@@ -7,7 +7,26 @@ feature 'Admin comments' do
login_as(admin.user)
end
scenario 'Restore', :js do
scenario "Do not show comments from blocked users" do
comment = create(:comment, :hidden, body: "SPAM from SPAMMER")
proposal = create(:proposal, author: comment.author)
create(:comment, commentable: proposal, user: comment.author, body: "Good Proposal!")
visit admin_comments_path
expect(page).to have_content("SPAM from SPAMMER")
expect(page).not_to have_content("Good Proposal!")
visit proposal_path(proposal)
within("#proposal_#{proposal.id}") do
click_link 'Ban author'
end
visit admin_comments_path
expect(page).to_not have_content("SPAM from SPAMMER")
expect(page).not_to have_content("Good Proposal!")
end
scenario "Restore" do
comment = create(:comment, :hidden, body: 'Not really SPAM')
visit admin_comments_path
@@ -18,7 +37,7 @@ feature 'Admin comments' do
expect(comment.reload).to_not be_hidden
end
scenario 'Confirm hide' do
scenario "Confirm hide" do
comment = create(:comment, :hidden, body: 'SPAM')
visit admin_comments_path