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:
kikito
2015-08-27 11:43:58 +02:00
parent 17b33f1030
commit cd982768f2
15 changed files with 111 additions and 106 deletions

View File

@@ -164,6 +164,11 @@ body.admin {
font-size: rem-calc(12); font-size: rem-calc(12);
} }
.ignored {
color: $text-medium;
font-size: rem-calc(12);
}
.rejected { .rejected {
color: $delete; color: $delete;
} }

View File

@@ -19,8 +19,8 @@ class Moderation::CommentsController < Moderation::BaseController
redirect_to request.query_parameters.merge(action: :index) redirect_to request.query_parameters.merge(action: :index)
end end
def archive def ignore_flag
@comment.archive @comment.ignore_flag
redirect_to request.query_parameters.merge(action: :index) redirect_to request.query_parameters.merge(action: :index)
end end
@@ -31,7 +31,7 @@ class Moderation::CommentsController < Moderation::BaseController
end end
def set_valid_filters def set_valid_filters
@valid_filters = %w{all pending archived} @valid_filters = %w{all pending_flag_review with_ignored_flag}
end end
def parse_filter def parse_filter

View File

@@ -19,8 +19,8 @@ class Moderation::DebatesController < Moderation::BaseController
redirect_to request.query_parameters.merge(action: :index) redirect_to request.query_parameters.merge(action: :index)
end end
def archive def ignore_flag
@debate.archive @debate.ignore_flag
redirect_to request.query_parameters.merge(action: :index) redirect_to request.query_parameters.merge(action: :index)
end end
@@ -31,7 +31,7 @@ class Moderation::DebatesController < Moderation::BaseController
end end
def set_valid_filters def set_valid_filters
@valid_filters = %w{all pending archived} @valid_filters = %w{all pending_flag_review with_ignored_flag}
end end
def parse_filter def parse_filter

View File

@@ -53,14 +53,14 @@ class Ability
can :hide, Comment, hidden_at: nil can :hide, Comment, hidden_at: nil
cannot :hide, Comment, user_id: user.id cannot :hide, Comment, user_id: user.id
can :archive, Comment, archived_at: nil, hidden_at: nil can :ignore_flag, Comment, ignored_flag_at: nil, hidden_at: nil
cannot :archive, Comment, user_id: user.id cannot :ignore_flag, Comment, user_id: user.id
can :hide, Debate, hidden_at: nil can :hide, Debate, hidden_at: nil
cannot :hide, Debate, author_id: user.id cannot :hide, Debate, author_id: user.id
can :archive, Debate, archived_at: nil, hidden_at: nil can :ignore_flag, Debate, ignored_flag_at: nil, hidden_at: nil
cannot :archive, Debate, author_id: user.id cannot :ignore_flag, Debate, author_id: user.id
can :hide, User can :hide, User
cannot :hide, User, id: user.id cannot :hide, User, id: user.id

View File

@@ -17,8 +17,8 @@ class Comment < ActiveRecord::Base
scope :recent, -> { order(id: :desc) } scope :recent, -> { order(id: :desc) }
scope :sorted_for_moderation, -> { order(flags_count: :desc, updated_at: :desc) } scope :sorted_for_moderation, -> { order(flags_count: :desc, updated_at: :desc) }
scope :pending, -> { where(archived_at: nil, hidden_at: nil) } scope :pending_flag_review, -> { where(ignored_flag_at: nil, hidden_at: nil) }
scope :archived, -> { where("archived_at IS NOT NULL AND hidden_at IS NULL") } scope :with_ignored_flag, -> { where("ignored_flag_at IS NOT NULL AND hidden_at IS NULL") }
scope :flagged, -> { where("flags_count > 0") } scope :flagged, -> { where("flags_count > 0") }
scope :for_render, -> { with_hidden.includes(user: :organization) } scope :for_render, -> { with_hidden.includes(user: :organization) }
@@ -65,8 +65,12 @@ class Comment < ActiveRecord::Base
hidden? || user.hidden? hidden? || user.hidden?
end end
def archived? def ignored_flag?
archived_at.present? ignored_flag_at.present?
end
def ignore_flag
update(ignored_flag_at: Time.now)
end end
def as_administrator? def as_administrator?
@@ -77,10 +81,6 @@ class Comment < ActiveRecord::Base
moderator_id.present? moderator_id.present?
end 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 # 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 # Remove when https://github.com/collectiveidea/awesome_nested_set/issues/294 is fixed
# and reset counters using # and reset counters using

View File

@@ -24,8 +24,8 @@ class Debate < ActiveRecord::Base
before_validation :sanitize_tag_list before_validation :sanitize_tag_list
scope :sorted_for_moderation, -> { order(flags_count: :desc, updated_at: :desc) } scope :sorted_for_moderation, -> { order(flags_count: :desc, updated_at: :desc) }
scope :pending, -> { where(archived_at: nil, hidden_at: nil) } scope :pending_flag_review, -> { where(ignored_flag_at: nil, hidden_at: nil) }
scope :archived, -> { where("archived_at IS NOT NULL AND hidden_at IS NULL") } scope :with_ignored_flag, -> { where("ignored_flag_at IS NOT NULL AND hidden_at IS NULL") }
scope :flagged, -> { where("flags_count > 0") } scope :flagged, -> { where("flags_count > 0") }
scope :for_render, -> { includes(:tags) } scope :for_render, -> { includes(:tags) }
@@ -75,12 +75,12 @@ class Debate < ActiveRecord::Base
count < 0 ? 0 : count count < 0 ? 0 : count
end end
def archived? def ignored_flag?
archived_at.present? ignored_flag_at.present?
end end
def archive def ignore_flag
update(archived_at: Time.now) update(ignored_flag_at: Time.now)
end end
protected protected

View File

@@ -39,14 +39,14 @@
<td> <td>
<%= link_to t("moderation.comments.index.hide"), hide_in_moderation_screen_moderation_comment_path(comment, request.query_parameters), method: :put, class: "delete" %> <%= link_to t("moderation.comments.index.hide"), hide_in_moderation_screen_moderation_comment_path(comment, request.query_parameters), method: :put, class: "delete" %>
</td> </td>
<% if can? :archive, comment %> <% if can? :ignore_flag, comment %>
<td> <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> </td>
<% end %> <% end %>
<% if comment.archived? %> <% if comment.ignored_flag? %>
<td class="archived"> <td class="ignored">
<%= t("moderation.comments.index.archived") %> <%= t("moderation.comments.index.ignored_flag") %>
</td> </td>
<% end %> <% end %>
</tr> </tr>

View File

@@ -38,14 +38,14 @@
<td> <td>
<%= link_to t("moderation.debates.index.hide"), hide_in_moderation_screen_moderation_debate_path(debate, request.query_parameters), method: :put, class: "delete" %> <%= link_to t("moderation.debates.index.hide"), hide_in_moderation_screen_moderation_debate_path(debate, request.query_parameters), method: :put, class: "delete" %>
</td> </td>
<% if can? :archive, debate %> <% if can? :ignore_flag, debate %>
<td> <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> </td>
<% end %> <% end %>
<% if debate.archived? %> <% if debate.ignored_flag? %>
<td class="archived"> <td class="ignored">
<%= t("moderation.debates.index.archived") %> <%= t("moderation.debates.index.ignored_flag") %>
</td> </td>
<% end %> <% end %>
</tr> </tr>

View File

@@ -16,13 +16,13 @@ en:
commentable: Root commentable: Root
comment: Comment comment: Comment
hide: Hide hide: Hide
archive: Archive ignore_flag: Ignore
archived: Archived ignored_flag: Ignored
filter: Filter filter: Filter
filters: filters:
all: All all: All
pending: Pending pending_flag_review: Pending
archived: Archived with_ignored_flag: Ignored
debates: debates:
index: index:
title: Debates flagged as inappropriate title: Debates flagged as inappropriate
@@ -33,10 +33,10 @@ en:
description: Description description: Description
actions: Actions actions: Actions
hide: Hide hide: Hide
archive: Archive ignore_flag: Ignore
archived: Archived ignored_flag: Ignored
filter: Filter filter: Filter
filters: filters:
all: All all: All
pending: Pending pending_flag_review: Pending
archived: Archived with_ignored_flag: Ignored

View File

@@ -16,13 +16,13 @@ es:
commentable: Raíz commentable: Raíz
comment: Comentario comment: Comentario
hide: Ocultar hide: Ocultar
archive: Archivar ignore_flag: Ignorar
archived: Archivado ignored_flag: Ignorado
filter: Filtrar filter: Filtrar
filters: filters:
all: Todos all: Todos
pending: Pendientes pending_flag_review: Pendientes
archived: Archivados with_ignored_flag: Ignorados
debates: debates:
index: index:
title: Debates denunciados como inapropiados title: Debates denunciados como inapropiados
@@ -33,10 +33,10 @@ es:
description: Descripción description: Descripción
actions: Acciones actions: Acciones
hide: Ocultar hide: Ocultar
archive: Archivar ignore_flag: Ignorar
archived: Archivado ignored_flag: Ignorado
filter: Filtrar filter: Filtrar
filters: filters:
all: Todos all: Todos
pending: Pendientes pending_flag_review: Pendientes
archived: Archivados with_ignored_flag: Ignorados

View File

@@ -88,7 +88,7 @@ Rails.application.routes.draw do
member do member do
put :hide put :hide
put :hide_in_moderation_screen put :hide_in_moderation_screen
put :archive put :ignore_flag
end end
end end
@@ -96,7 +96,7 @@ Rails.application.routes.draw do
member do member do
put :hide put :hide
put :hide_in_moderation_screen put :hide_in_moderation_screen
put :archive put :ignore_flag
end end
end end
end end

View File

@@ -22,8 +22,8 @@ FactoryGirl.define do
hidden_at Time.now hidden_at Time.now
end end
trait :archived do trait :with_ignored_flag do
archived_at Time.now ignored_flag_at Time.now
end end
trait :flagged do trait :flagged do
@@ -51,8 +51,8 @@ FactoryGirl.define do
hidden_at Time.now hidden_at Time.now
end end
trait :archived do trait :with_ignored_flag do
archived_at Time.now ignored_flag_at Time.now
end end
trait :flagged do trait :flagged do

View File

@@ -104,57 +104,57 @@ feature 'Moderate Comments' do
visit moderation_comments_path visit moderation_comments_path
expect(page).to_not have_link('All') expect(page).to_not have_link('All')
expect(page).to have_link('Pending') expect(page).to have_link('Pending')
expect(page).to have_link('Archived') expect(page).to have_link('Ignored')
visit moderation_comments_path(filter: 'all') visit moderation_comments_path(filter: 'all')
expect(page).to_not have_link('All') expect(page).to_not have_link('All')
expect(page).to have_link('Pending') 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 have_link('All')
expect(page).to_not have_link('Pending') 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('All')
expect(page).to have_link('Pending') expect(page).to have_link('Pending')
expect(page).to_not have_link('Archived') expect(page).to_not have_link('Ignored')
end end
scenario "Filtering comments" do scenario "Filtering comments" do
create(:comment, :flagged, body: "Pending comment") create(:comment, :flagged, body: "Pending comment")
create(:comment, :flagged, :hidden, body: "Hidden 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') visit moderation_comments_path(filter: 'all')
expect(page).to have_content('Pending comment') expect(page).to have_content('Pending comment')
expect(page).to_not have_content('Hidden 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 have_content('Pending comment')
expect(page).to_not have_content('Hidden 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('Pending comment')
expect(page).to_not have_content('Hidden comment') expect(page).to_not have_content('Hidden comment')
expect(page).to have_content('Archived comment') expect(page).to have_content('Ignored comment')
end end
scenario "Reviewing links remember the pagination setting and the filter" do scenario "Reviewing links remember the pagination setting and the filter" do
per_page = Kaminari.config.default_per_page per_page = Kaminari.config.default_per_page
(per_page + 2).times { create(:comment, :flagged) } (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) uri = URI.parse(current_url)
query_params = Rack::Utils.parse_nested_query(uri.query).symbolize_keys 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') expect(query_params[:page]).to eq('2')
end end
@@ -172,7 +172,7 @@ feature 'Moderate Comments' do
expect(page).to have_content('spammy spam') expect(page).to have_content('spammy spam')
expect(page).to have_content('1') expect(page).to have_content('1')
expect(page).to have_link('Hide') expect(page).to have_link('Hide')
expect(page).to have_link('Archive') expect(page).to have_link('Ignore')
end end
end end
@@ -187,18 +187,18 @@ feature 'Moderate Comments' do
expect(@comment.reload).to be_hidden expect(@comment.reload).to be_hidden
end end
scenario 'Marking the comment as archived' do scenario 'Marking the comment as ignored' do
within("#comment_#{@comment.id}") do within("#comment_#{@comment.id}") do
click_link('Archive') click_link('Ignore')
end end
expect(current_path).to eq(moderation_comments_path) expect(current_path).to eq(moderation_comments_path)
within("#comment_#{@comment.id}") do within("#comment_#{@comment.id}") do
expect(page).to have_content('Archived') expect(page).to have_content('Ignored')
end end
expect(@comment.reload).to be_archived expect(@comment.reload).to be_ignored_flag
end end
end end
end end

View File

@@ -47,57 +47,57 @@ feature 'Moderate debates' do
visit moderation_debates_path visit moderation_debates_path
expect(page).to_not have_link('All') expect(page).to_not have_link('All')
expect(page).to have_link('Pending') expect(page).to have_link('Pending')
expect(page).to have_link('Archived') expect(page).to have_link('Ignored')
visit moderation_debates_path(filter: 'all') visit moderation_debates_path(filter: 'all')
expect(page).to_not have_link('All') expect(page).to_not have_link('All')
expect(page).to have_link('Pending') 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 have_link('All')
expect(page).to_not have_link('Pending') 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('All')
expect(page).to have_link('Pending') expect(page).to have_link('Pending')
expect(page).to_not have_link('Archived') expect(page).to_not have_link('Ignored')
end end
scenario "Filtering debates" do scenario "Filtering debates" do
create(:debate, :flagged, title: "Pending debate") create(:debate, :flagged, title: "Pending debate")
create(:debate, :flagged, :hidden, title: "Hidden 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') visit moderation_debates_path(filter: 'all')
expect(page).to have_content('Pending debate') expect(page).to have_content('Pending debate')
expect(page).to_not have_content('Hidden 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 have_content('Pending debate')
expect(page).to_not have_content('Hidden 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('Pending debate')
expect(page).to_not have_content('Hidden debate') expect(page).to_not have_content('Hidden debate')
expect(page).to have_content('Archived debate') expect(page).to have_content('Ignored debate')
end end
scenario "Reviewing links remember the pagination setting and the filter" do scenario "Reviewing links remember the pagination setting and the filter" do
per_page = Kaminari.config.default_per_page per_page = Kaminari.config.default_per_page
(per_page + 2).times { create(:debate, :flagged) } (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) uri = URI.parse(current_url)
query_params = Rack::Utils.parse_nested_query(uri.query).symbolize_keys 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') expect(query_params[:page]).to eq('2')
end end
@@ -114,7 +114,7 @@ feature 'Moderate debates' do
expect(page).to have_content('buy buy buy') expect(page).to have_content('buy buy buy')
expect(page).to have_content('1') expect(page).to have_content('1')
expect(page).to have_link('Hide') expect(page).to have_link('Hide')
expect(page).to have_link('Archive') expect(page).to have_link('Ignore')
end end
end end
@@ -129,18 +129,18 @@ feature 'Moderate debates' do
expect(@debate.reload).to be_hidden expect(@debate.reload).to be_hidden
end end
scenario 'Marking the debate as archived' do scenario 'Marking the debate as ignored' do
within("#debate_#{@debate.id}") do within("#debate_#{@debate.id}") do
click_link('Archive') click_link('Ignore')
end end
expect(current_path).to eq(moderation_debates_path) expect(current_path).to eq(moderation_debates_path)
within("#debate_#{@debate.id}") do within("#debate_#{@debate.id}") do
expect(page).to have_content('Archived') expect(page).to have_content('Ignored')
end end
expect(@debate.reload).to be_archived expect(@debate.reload).to be_ignored_flag
end end
end end
end end

View File

@@ -131,8 +131,8 @@ describe Ability do
let(:own_debate) { create(:debate, author: user) } let(:own_debate) { create(:debate, author: user) }
let(:hidden_comment) { create(:comment, :hidden) } let(:hidden_comment) { create(:comment, :hidden) }
let(:hidden_debate) { create(:debate, :hidden) } let(:hidden_debate) { create(:debate, :hidden) }
let(:archived_comment) { create(:comment, :archived) } let(:ignored_comment) { create(:comment, :with_ignored_flag) }
let(:archived_debate) { create(:debate, :archived) } let(:ignored_debate) { create(:debate, :with_ignored_flag) }
it { should be_able_to(:hide, comment) } it { should be_able_to(:hide, comment) }
it { should be_able_to(:hide_in_moderation_screen, 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, hidden_debate) }
it { should_not be_able_to(:hide, own_debate) } it { should_not be_able_to(:hide, own_debate) }
it { should be_able_to(:archive, comment) } it { should be_able_to(:ignore_flag, comment) }
it { should_not be_able_to(:archive, hidden_comment) } it { should_not be_able_to(:ignore_flag, hidden_comment) }
it { should_not be_able_to(:archive, archived_comment) } it { should_not be_able_to(:ignore_flag, ignored_comment) }
it { should_not be_able_to(:archive, own_comment) } it { should_not be_able_to(:ignore_flag, own_comment) }
it { should be_able_to(:archive, debate) } it { should be_able_to(:ignore_flag, debate) }
it { should_not be_able_to(:archive, hidden_debate) } it { should_not be_able_to(:ignore_flag, hidden_debate) }
it { should_not be_able_to(:archive, archived_debate) } it { should_not be_able_to(:ignore_flag, ignored_debate) }
it { should_not be_able_to(:archive, own_debate) } it { should_not be_able_to(:ignore_flag, own_debate) }
it { should_not be_able_to(:hide, user) } it { should_not be_able_to(:hide, user) }
it { should be_able_to(:hide, other_user) } it { should be_able_to(:hide, other_user) }