Renames the "archive" action to "ignore_flag" (+)
* archived_at -> ignored_flag_at * archived? -> ignored_flag? * archive -> ignore_flag * pending -> pending_flag_review * archived (scope) -> with_ignored_flag * I18n changes
This commit is contained in:
@@ -164,6 +164,11 @@ body.admin {
|
||||
font-size: rem-calc(12);
|
||||
}
|
||||
|
||||
.ignored {
|
||||
color: $text-medium;
|
||||
font-size: rem-calc(12);
|
||||
}
|
||||
|
||||
.rejected {
|
||||
color: $delete;
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@ class Moderation::CommentsController < Moderation::BaseController
|
||||
redirect_to request.query_parameters.merge(action: :index)
|
||||
end
|
||||
|
||||
def archive
|
||||
@comment.archive
|
||||
def ignore_flag
|
||||
@comment.ignore_flag
|
||||
redirect_to request.query_parameters.merge(action: :index)
|
||||
end
|
||||
|
||||
@@ -31,7 +31,7 @@ class Moderation::CommentsController < Moderation::BaseController
|
||||
end
|
||||
|
||||
def set_valid_filters
|
||||
@valid_filters = %w{all pending archived}
|
||||
@valid_filters = %w{all pending_flag_review with_ignored_flag}
|
||||
end
|
||||
|
||||
def parse_filter
|
||||
|
||||
@@ -19,8 +19,8 @@ class Moderation::DebatesController < Moderation::BaseController
|
||||
redirect_to request.query_parameters.merge(action: :index)
|
||||
end
|
||||
|
||||
def archive
|
||||
@debate.archive
|
||||
def ignore_flag
|
||||
@debate.ignore_flag
|
||||
redirect_to request.query_parameters.merge(action: :index)
|
||||
end
|
||||
|
||||
@@ -31,7 +31,7 @@ class Moderation::DebatesController < Moderation::BaseController
|
||||
end
|
||||
|
||||
def set_valid_filters
|
||||
@valid_filters = %w{all pending archived}
|
||||
@valid_filters = %w{all pending_flag_review with_ignored_flag}
|
||||
end
|
||||
|
||||
def parse_filter
|
||||
|
||||
@@ -53,14 +53,14 @@ class Ability
|
||||
can :hide, Comment, hidden_at: nil
|
||||
cannot :hide, Comment, user_id: user.id
|
||||
|
||||
can :archive, Comment, archived_at: nil, hidden_at: nil
|
||||
cannot :archive, Comment, user_id: user.id
|
||||
can :ignore_flag, Comment, ignored_flag_at: nil, hidden_at: nil
|
||||
cannot :ignore_flag, Comment, user_id: user.id
|
||||
|
||||
can :hide, Debate, hidden_at: nil
|
||||
cannot :hide, Debate, author_id: user.id
|
||||
|
||||
can :archive, Debate, archived_at: nil, hidden_at: nil
|
||||
cannot :archive, Debate, author_id: user.id
|
||||
can :ignore_flag, Debate, ignored_flag_at: nil, hidden_at: nil
|
||||
cannot :ignore_flag, Debate, author_id: user.id
|
||||
|
||||
can :hide, User
|
||||
cannot :hide, User, id: user.id
|
||||
|
||||
@@ -17,8 +17,8 @@ class Comment < ActiveRecord::Base
|
||||
scope :recent, -> { order(id: :desc) }
|
||||
|
||||
scope :sorted_for_moderation, -> { order(flags_count: :desc, updated_at: :desc) }
|
||||
scope :pending, -> { where(archived_at: nil, hidden_at: nil) }
|
||||
scope :archived, -> { where("archived_at IS NOT NULL AND hidden_at IS NULL") }
|
||||
scope :pending_flag_review, -> { where(ignored_flag_at: nil, hidden_at: nil) }
|
||||
scope :with_ignored_flag, -> { where("ignored_flag_at IS NOT NULL AND hidden_at IS NULL") }
|
||||
scope :flagged, -> { where("flags_count > 0") }
|
||||
|
||||
scope :for_render, -> { with_hidden.includes(user: :organization) }
|
||||
@@ -65,8 +65,12 @@ class Comment < ActiveRecord::Base
|
||||
hidden? || user.hidden?
|
||||
end
|
||||
|
||||
def archived?
|
||||
archived_at.present?
|
||||
def ignored_flag?
|
||||
ignored_flag_at.present?
|
||||
end
|
||||
|
||||
def ignore_flag
|
||||
update(ignored_flag_at: Time.now)
|
||||
end
|
||||
|
||||
def as_administrator?
|
||||
@@ -77,10 +81,6 @@ class Comment < ActiveRecord::Base
|
||||
moderator_id.present?
|
||||
end
|
||||
|
||||
def archive
|
||||
update(archived_at: Time.now)
|
||||
end
|
||||
|
||||
# TODO: faking counter cache since there is a bug with acts_as_nested_set :counter_cache
|
||||
# Remove when https://github.com/collectiveidea/awesome_nested_set/issues/294 is fixed
|
||||
# and reset counters using
|
||||
|
||||
@@ -24,8 +24,8 @@ class Debate < ActiveRecord::Base
|
||||
before_validation :sanitize_tag_list
|
||||
|
||||
scope :sorted_for_moderation, -> { order(flags_count: :desc, updated_at: :desc) }
|
||||
scope :pending, -> { where(archived_at: nil, hidden_at: nil) }
|
||||
scope :archived, -> { where("archived_at IS NOT NULL AND hidden_at IS NULL") }
|
||||
scope :pending_flag_review, -> { where(ignored_flag_at: nil, hidden_at: nil) }
|
||||
scope :with_ignored_flag, -> { where("ignored_flag_at IS NOT NULL AND hidden_at IS NULL") }
|
||||
scope :flagged, -> { where("flags_count > 0") }
|
||||
scope :for_render, -> { includes(:tags) }
|
||||
|
||||
@@ -75,12 +75,12 @@ class Debate < ActiveRecord::Base
|
||||
count < 0 ? 0 : count
|
||||
end
|
||||
|
||||
def archived?
|
||||
archived_at.present?
|
||||
def ignored_flag?
|
||||
ignored_flag_at.present?
|
||||
end
|
||||
|
||||
def archive
|
||||
update(archived_at: Time.now)
|
||||
def ignore_flag
|
||||
update(ignored_flag_at: Time.now)
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
@@ -39,14 +39,14 @@
|
||||
<td>
|
||||
<%= link_to t("moderation.comments.index.hide"), hide_in_moderation_screen_moderation_comment_path(comment, request.query_parameters), method: :put, class: "delete" %>
|
||||
</td>
|
||||
<% if can? :archive, comment %>
|
||||
<% if can? :ignore_flag, comment %>
|
||||
<td>
|
||||
<%= link_to t("moderation.comments.index.archive"), archive_moderation_comment_path(comment, request.query_parameters), method: :put, class: "button radius tiny warning" %>
|
||||
<%= link_to t("moderation.comments.index.ignore_flag"), ignore_flag_moderation_comment_path(comment, request.query_parameters), method: :put, class: "button radius tiny warning" %>
|
||||
</td>
|
||||
<% end %>
|
||||
<% if comment.archived? %>
|
||||
<td class="archived">
|
||||
<%= t("moderation.comments.index.archived") %>
|
||||
<% if comment.ignored_flag? %>
|
||||
<td class="ignored">
|
||||
<%= t("moderation.comments.index.ignored_flag") %>
|
||||
</td>
|
||||
<% end %>
|
||||
</tr>
|
||||
|
||||
@@ -38,14 +38,14 @@
|
||||
<td>
|
||||
<%= link_to t("moderation.debates.index.hide"), hide_in_moderation_screen_moderation_debate_path(debate, request.query_parameters), method: :put, class: "delete" %>
|
||||
</td>
|
||||
<% if can? :archive, debate %>
|
||||
<% if can? :ignore_flag, debate %>
|
||||
<td>
|
||||
<%= link_to t("moderation.debates.index.archive"), archive_moderation_debate_path(debate, request.query_parameters), method: :put, class: "button radius tiny warning" %>
|
||||
<%= link_to t("moderation.debates.index.ignore_flag"), ignore_flag_moderation_debate_path(debate, request.query_parameters), method: :put, class: "button radius tiny warning" %>
|
||||
</td>
|
||||
<% end %>
|
||||
<% if debate.archived? %>
|
||||
<td class="archived">
|
||||
<%= t("moderation.debates.index.archived") %>
|
||||
<% if debate.ignored_flag? %>
|
||||
<td class="ignored">
|
||||
<%= t("moderation.debates.index.ignored_flag") %>
|
||||
</td>
|
||||
<% end %>
|
||||
</tr>
|
||||
|
||||
@@ -16,13 +16,13 @@ en:
|
||||
commentable: Root
|
||||
comment: Comment
|
||||
hide: Hide
|
||||
archive: Archive
|
||||
archived: Archived
|
||||
ignore_flag: Ignore
|
||||
ignored_flag: Ignored
|
||||
filter: Filter
|
||||
filters:
|
||||
all: All
|
||||
pending: Pending
|
||||
archived: Archived
|
||||
pending_flag_review: Pending
|
||||
with_ignored_flag: Ignored
|
||||
debates:
|
||||
index:
|
||||
title: Debates flagged as inappropriate
|
||||
@@ -33,10 +33,10 @@ en:
|
||||
description: Description
|
||||
actions: Actions
|
||||
hide: Hide
|
||||
archive: Archive
|
||||
archived: Archived
|
||||
ignore_flag: Ignore
|
||||
ignored_flag: Ignored
|
||||
filter: Filter
|
||||
filters:
|
||||
all: All
|
||||
pending: Pending
|
||||
archived: Archived
|
||||
pending_flag_review: Pending
|
||||
with_ignored_flag: Ignored
|
||||
|
||||
@@ -16,13 +16,13 @@ es:
|
||||
commentable: Raíz
|
||||
comment: Comentario
|
||||
hide: Ocultar
|
||||
archive: Archivar
|
||||
archived: Archivado
|
||||
ignore_flag: Ignorar
|
||||
ignored_flag: Ignorado
|
||||
filter: Filtrar
|
||||
filters:
|
||||
all: Todos
|
||||
pending: Pendientes
|
||||
archived: Archivados
|
||||
pending_flag_review: Pendientes
|
||||
with_ignored_flag: Ignorados
|
||||
debates:
|
||||
index:
|
||||
title: Debates denunciados como inapropiados
|
||||
@@ -33,10 +33,10 @@ es:
|
||||
description: Descripción
|
||||
actions: Acciones
|
||||
hide: Ocultar
|
||||
archive: Archivar
|
||||
archived: Archivado
|
||||
ignore_flag: Ignorar
|
||||
ignored_flag: Ignorado
|
||||
filter: Filtrar
|
||||
filters:
|
||||
all: Todos
|
||||
pending: Pendientes
|
||||
archived: Archivados
|
||||
pending_flag_review: Pendientes
|
||||
with_ignored_flag: Ignorados
|
||||
|
||||
@@ -88,7 +88,7 @@ Rails.application.routes.draw do
|
||||
member do
|
||||
put :hide
|
||||
put :hide_in_moderation_screen
|
||||
put :archive
|
||||
put :ignore_flag
|
||||
end
|
||||
end
|
||||
|
||||
@@ -96,7 +96,7 @@ Rails.application.routes.draw do
|
||||
member do
|
||||
put :hide
|
||||
put :hide_in_moderation_screen
|
||||
put :archive
|
||||
put :ignore_flag
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -22,8 +22,8 @@ FactoryGirl.define do
|
||||
hidden_at Time.now
|
||||
end
|
||||
|
||||
trait :archived do
|
||||
archived_at Time.now
|
||||
trait :with_ignored_flag do
|
||||
ignored_flag_at Time.now
|
||||
end
|
||||
|
||||
trait :flagged do
|
||||
@@ -51,8 +51,8 @@ FactoryGirl.define do
|
||||
hidden_at Time.now
|
||||
end
|
||||
|
||||
trait :archived do
|
||||
archived_at Time.now
|
||||
trait :with_ignored_flag do
|
||||
ignored_flag_at Time.now
|
||||
end
|
||||
|
||||
trait :flagged do
|
||||
|
||||
@@ -104,57 +104,57 @@ feature 'Moderate Comments' do
|
||||
visit moderation_comments_path
|
||||
expect(page).to_not have_link('All')
|
||||
expect(page).to have_link('Pending')
|
||||
expect(page).to have_link('Archived')
|
||||
expect(page).to have_link('Ignored')
|
||||
|
||||
visit moderation_comments_path(filter: 'all')
|
||||
expect(page).to_not have_link('All')
|
||||
expect(page).to have_link('Pending')
|
||||
expect(page).to have_link('Archived')
|
||||
expect(page).to have_link('Ignored')
|
||||
|
||||
visit moderation_comments_path(filter: 'pending')
|
||||
visit moderation_comments_path(filter: 'pending_flag_review')
|
||||
expect(page).to have_link('All')
|
||||
expect(page).to_not have_link('Pending')
|
||||
expect(page).to have_link('Archived')
|
||||
expect(page).to have_link('Ignored')
|
||||
|
||||
visit moderation_comments_path(filter: 'archived')
|
||||
visit moderation_comments_path(filter: 'with_ignored_flag')
|
||||
expect(page).to have_link('All')
|
||||
expect(page).to have_link('Pending')
|
||||
expect(page).to_not have_link('Archived')
|
||||
expect(page).to_not have_link('Ignored')
|
||||
end
|
||||
|
||||
scenario "Filtering comments" do
|
||||
create(:comment, :flagged, body: "Pending comment")
|
||||
create(:comment, :flagged, :hidden, body: "Hidden comment")
|
||||
create(:comment, :flagged, :archived, body: "Archived comment")
|
||||
create(:comment, :flagged, :with_ignored_flag, body: "Ignored comment")
|
||||
|
||||
visit moderation_comments_path(filter: 'all')
|
||||
expect(page).to have_content('Pending comment')
|
||||
expect(page).to_not have_content('Hidden comment')
|
||||
expect(page).to have_content('Archived comment')
|
||||
expect(page).to have_content('Ignored comment')
|
||||
|
||||
visit moderation_comments_path(filter: 'pending')
|
||||
visit moderation_comments_path(filter: 'pending_flag_review')
|
||||
expect(page).to have_content('Pending comment')
|
||||
expect(page).to_not have_content('Hidden comment')
|
||||
expect(page).to_not have_content('Archived comment')
|
||||
expect(page).to_not have_content('Ignored comment')
|
||||
|
||||
visit moderation_comments_path(filter: 'archived')
|
||||
visit moderation_comments_path(filter: 'with_ignored_flag')
|
||||
expect(page).to_not have_content('Pending comment')
|
||||
expect(page).to_not have_content('Hidden comment')
|
||||
expect(page).to have_content('Archived comment')
|
||||
expect(page).to have_content('Ignored comment')
|
||||
end
|
||||
|
||||
scenario "Reviewing links remember the pagination setting and the filter" do
|
||||
per_page = Kaminari.config.default_per_page
|
||||
(per_page + 2).times { create(:comment, :flagged) }
|
||||
|
||||
visit moderation_comments_path(filter: 'pending', page: 2)
|
||||
visit moderation_comments_path(filter: 'pending_flag_review', page: 2)
|
||||
|
||||
click_link('Archive', match: :first, exact: true)
|
||||
click_link('Ignore', match: :first, exact: true)
|
||||
|
||||
uri = URI.parse(current_url)
|
||||
query_params = Rack::Utils.parse_nested_query(uri.query).symbolize_keys
|
||||
|
||||
expect(query_params[:filter]).to eq('pending')
|
||||
expect(query_params[:filter]).to eq('pending_flag_review')
|
||||
expect(query_params[:page]).to eq('2')
|
||||
end
|
||||
|
||||
@@ -172,7 +172,7 @@ feature 'Moderate Comments' do
|
||||
expect(page).to have_content('spammy spam')
|
||||
expect(page).to have_content('1')
|
||||
expect(page).to have_link('Hide')
|
||||
expect(page).to have_link('Archive')
|
||||
expect(page).to have_link('Ignore')
|
||||
end
|
||||
end
|
||||
|
||||
@@ -187,18 +187,18 @@ feature 'Moderate Comments' do
|
||||
expect(@comment.reload).to be_hidden
|
||||
end
|
||||
|
||||
scenario 'Marking the comment as archived' do
|
||||
scenario 'Marking the comment as ignored' do
|
||||
within("#comment_#{@comment.id}") do
|
||||
click_link('Archive')
|
||||
click_link('Ignore')
|
||||
end
|
||||
|
||||
expect(current_path).to eq(moderation_comments_path)
|
||||
|
||||
within("#comment_#{@comment.id}") do
|
||||
expect(page).to have_content('Archived')
|
||||
expect(page).to have_content('Ignored')
|
||||
end
|
||||
|
||||
expect(@comment.reload).to be_archived
|
||||
expect(@comment.reload).to be_ignored_flag
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -47,57 +47,57 @@ feature 'Moderate debates' do
|
||||
visit moderation_debates_path
|
||||
expect(page).to_not have_link('All')
|
||||
expect(page).to have_link('Pending')
|
||||
expect(page).to have_link('Archived')
|
||||
expect(page).to have_link('Ignored')
|
||||
|
||||
visit moderation_debates_path(filter: 'all')
|
||||
expect(page).to_not have_link('All')
|
||||
expect(page).to have_link('Pending')
|
||||
expect(page).to have_link('Archived')
|
||||
expect(page).to have_link('Ignored')
|
||||
|
||||
visit moderation_debates_path(filter: 'pending')
|
||||
visit moderation_debates_path(filter: 'pending_flag_review')
|
||||
expect(page).to have_link('All')
|
||||
expect(page).to_not have_link('Pending')
|
||||
expect(page).to have_link('Archived')
|
||||
expect(page).to have_link('Ignored')
|
||||
|
||||
visit moderation_debates_path(filter: 'archived')
|
||||
visit moderation_debates_path(filter: 'with_ignored_flag')
|
||||
expect(page).to have_link('All')
|
||||
expect(page).to have_link('Pending')
|
||||
expect(page).to_not have_link('Archived')
|
||||
expect(page).to_not have_link('Ignored')
|
||||
end
|
||||
|
||||
scenario "Filtering debates" do
|
||||
create(:debate, :flagged, title: "Pending debate")
|
||||
create(:debate, :flagged, :hidden, title: "Hidden debate")
|
||||
create(:debate, :flagged, :archived, title: "Archived debate")
|
||||
create(:debate, :flagged, :with_ignored_flag, title: "Ignored debate")
|
||||
|
||||
visit moderation_debates_path(filter: 'all')
|
||||
expect(page).to have_content('Pending debate')
|
||||
expect(page).to_not have_content('Hidden debate')
|
||||
expect(page).to have_content('Archived debate')
|
||||
expect(page).to have_content('Ignored debate')
|
||||
|
||||
visit moderation_debates_path(filter: 'pending')
|
||||
visit moderation_debates_path(filter: 'pending_flag_review')
|
||||
expect(page).to have_content('Pending debate')
|
||||
expect(page).to_not have_content('Hidden debate')
|
||||
expect(page).to_not have_content('Archived debate')
|
||||
expect(page).to_not have_content('Ignored debate')
|
||||
|
||||
visit moderation_debates_path(filter: 'archived')
|
||||
visit moderation_debates_path(filter: 'with_ignored_flag')
|
||||
expect(page).to_not have_content('Pending debate')
|
||||
expect(page).to_not have_content('Hidden debate')
|
||||
expect(page).to have_content('Archived debate')
|
||||
expect(page).to have_content('Ignored debate')
|
||||
end
|
||||
|
||||
scenario "Reviewing links remember the pagination setting and the filter" do
|
||||
per_page = Kaminari.config.default_per_page
|
||||
(per_page + 2).times { create(:debate, :flagged) }
|
||||
|
||||
visit moderation_debates_path(filter: 'pending', page: 2)
|
||||
visit moderation_debates_path(filter: 'pending_flag_review', page: 2)
|
||||
|
||||
click_link('Archive', match: :first, exact: true)
|
||||
click_link('Ignore', match: :first, exact: true)
|
||||
|
||||
uri = URI.parse(current_url)
|
||||
query_params = Rack::Utils.parse_nested_query(uri.query).symbolize_keys
|
||||
|
||||
expect(query_params[:filter]).to eq('pending')
|
||||
expect(query_params[:filter]).to eq('pending_flag_review')
|
||||
expect(query_params[:page]).to eq('2')
|
||||
end
|
||||
|
||||
@@ -114,7 +114,7 @@ feature 'Moderate debates' do
|
||||
expect(page).to have_content('buy buy buy')
|
||||
expect(page).to have_content('1')
|
||||
expect(page).to have_link('Hide')
|
||||
expect(page).to have_link('Archive')
|
||||
expect(page).to have_link('Ignore')
|
||||
end
|
||||
end
|
||||
|
||||
@@ -129,18 +129,18 @@ feature 'Moderate debates' do
|
||||
expect(@debate.reload).to be_hidden
|
||||
end
|
||||
|
||||
scenario 'Marking the debate as archived' do
|
||||
scenario 'Marking the debate as ignored' do
|
||||
within("#debate_#{@debate.id}") do
|
||||
click_link('Archive')
|
||||
click_link('Ignore')
|
||||
end
|
||||
|
||||
expect(current_path).to eq(moderation_debates_path)
|
||||
|
||||
within("#debate_#{@debate.id}") do
|
||||
expect(page).to have_content('Archived')
|
||||
expect(page).to have_content('Ignored')
|
||||
end
|
||||
|
||||
expect(@debate.reload).to be_archived
|
||||
expect(@debate.reload).to be_ignored_flag
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -131,8 +131,8 @@ describe Ability do
|
||||
let(:own_debate) { create(:debate, author: user) }
|
||||
let(:hidden_comment) { create(:comment, :hidden) }
|
||||
let(:hidden_debate) { create(:debate, :hidden) }
|
||||
let(:archived_comment) { create(:comment, :archived) }
|
||||
let(:archived_debate) { create(:debate, :archived) }
|
||||
let(:ignored_comment) { create(:comment, :with_ignored_flag) }
|
||||
let(:ignored_debate) { create(:debate, :with_ignored_flag) }
|
||||
|
||||
it { should be_able_to(:hide, comment) }
|
||||
it { should be_able_to(:hide_in_moderation_screen, comment) }
|
||||
@@ -144,15 +144,15 @@ describe Ability do
|
||||
it { should_not be_able_to(:hide, hidden_debate) }
|
||||
it { should_not be_able_to(:hide, own_debate) }
|
||||
|
||||
it { should be_able_to(:archive, comment) }
|
||||
it { should_not be_able_to(:archive, hidden_comment) }
|
||||
it { should_not be_able_to(:archive, archived_comment) }
|
||||
it { should_not be_able_to(:archive, own_comment) }
|
||||
it { should be_able_to(:ignore_flag, comment) }
|
||||
it { should_not be_able_to(:ignore_flag, hidden_comment) }
|
||||
it { should_not be_able_to(:ignore_flag, ignored_comment) }
|
||||
it { should_not be_able_to(:ignore_flag, own_comment) }
|
||||
|
||||
it { should be_able_to(:archive, debate) }
|
||||
it { should_not be_able_to(:archive, hidden_debate) }
|
||||
it { should_not be_able_to(:archive, archived_debate) }
|
||||
it { should_not be_able_to(:archive, own_debate) }
|
||||
it { should be_able_to(:ignore_flag, debate) }
|
||||
it { should_not be_able_to(:ignore_flag, hidden_debate) }
|
||||
it { should_not be_able_to(:ignore_flag, ignored_debate) }
|
||||
it { should_not be_able_to(:ignore_flag, own_debate) }
|
||||
|
||||
it { should_not be_able_to(:hide, user) }
|
||||
it { should be_able_to(:hide, other_user) }
|
||||
|
||||
Reference in New Issue
Block a user