Merge pull request #384 from AyuntamientoMadrid/pending-filter-in-admin
Pending filters in admin
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
class Admin::CommentsController < Admin::BaseController
|
||||
has_filters %w{all with_confirmed_hide}
|
||||
has_filters %w{without_confirmed_hide all with_confirmed_hide}
|
||||
|
||||
before_action :load_comment, only: [:confirm_hide, :restore]
|
||||
|
||||
def index
|
||||
@comments = Comment.only_hidden.send(@current_filter).page(params[:page])
|
||||
@comments = Comment.only_hidden.send(@current_filter).order(hidden_at: :desc).page(params[:page])
|
||||
end
|
||||
|
||||
def confirm_hide
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
class Admin::DebatesController < Admin::BaseController
|
||||
has_filters %w{all with_confirmed_hide}, only: :index
|
||||
has_filters %w{without_confirmed_hide all with_confirmed_hide}, only: :index
|
||||
|
||||
before_action :load_debate, only: [:confirm_hide, :restore]
|
||||
|
||||
def index
|
||||
@debates = Debate.only_hidden.send(@current_filter).page(params[:page])
|
||||
@debates = Debate.only_hidden.send(@current_filter).order(hidden_at: :desc).page(params[:page])
|
||||
end
|
||||
|
||||
def confirm_hide
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class Admin::UsersController < Admin::BaseController
|
||||
has_filters %w{all with_confirmed_hide}, only: :index
|
||||
has_filters %w{without_confirmed_hide all with_confirmed_hide}, only: :index
|
||||
|
||||
before_action :load_user, only: [:confirm_hide, :restore]
|
||||
|
||||
|
||||
@@ -18,11 +18,12 @@
|
||||
method: :put,
|
||||
data: { confirm: t("admin.actions.confirm") },
|
||||
class: "button radius tiny success right" %>
|
||||
|
||||
<%= link_to t("admin.actions.confirm_hide"),
|
||||
confirm_hide_admin_comment_path(comment, request.query_parameters),
|
||||
method: :put,
|
||||
class: "button radius tiny warning right" %>
|
||||
<% unless comment.confirmed_hide? %>
|
||||
<%= link_to t("admin.actions.confirm_hide"),
|
||||
confirm_hide_admin_comment_path(comment, request.query_parameters),
|
||||
method: :put,
|
||||
class: "button radius tiny warning right" %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
|
||||
@@ -15,10 +15,12 @@
|
||||
data: { confirm: t("admin.actions.confirm") },
|
||||
class: "button radius tiny success right" %>
|
||||
|
||||
<%= link_to t("admin.actions.confirm_hide"),
|
||||
confirm_hide_admin_debate_path(debate, request.query_parameters),
|
||||
method: :put,
|
||||
class: "button radius tiny warning right" %>
|
||||
<% unless debate.confirmed_hide? %>
|
||||
<%= link_to t("admin.actions.confirm_hide"),
|
||||
confirm_hide_admin_debate_path(debate, request.query_parameters),
|
||||
method: :put,
|
||||
class: "button radius tiny warning right" %>
|
||||
<% end %>
|
||||
</li>
|
||||
<% end %>
|
||||
</ul>
|
||||
|
||||
@@ -14,11 +14,12 @@
|
||||
method: :put,
|
||||
data: { confirm: t("admin.actions.confirm") },
|
||||
class: "button radius tiny success right" %>
|
||||
|
||||
<%= link_to t("admin.actions.confirm_hide"),
|
||||
<% unless user.confirmed_hide? %>
|
||||
<%= link_to t("admin.actions.confirm_hide"),
|
||||
confirm_hide_admin_user_path(user, request.query_parameters),
|
||||
method: :put,
|
||||
class: "button radius tiny warning right" %>
|
||||
<% end %>
|
||||
</li>
|
||||
<% end %>
|
||||
</ul>
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
<%= f.submit comment_button_text(parent_id), class: "button radius small inline-block" %>
|
||||
|
||||
<% if can? :comment_as_moderator, commentable %>º
|
||||
<% if can? :comment_as_moderator, commentable %>
|
||||
<div class="right">
|
||||
<%= f.check_box :as_moderator, id: "comment-as-moderator-#{css_id}", label: false %>
|
||||
<%= label_tag "comment-as-moderator-#{css_id}", t("comments.form.comment_as_moderator"), class: "checkbox" %>
|
||||
|
||||
@@ -59,6 +59,7 @@ en:
|
||||
filters:
|
||||
all: All
|
||||
with_confirmed_hide: Confirmed
|
||||
without_confirmed_hide: Pending
|
||||
debates:
|
||||
index:
|
||||
title: Hidden debates
|
||||
@@ -66,6 +67,7 @@ en:
|
||||
filters:
|
||||
all: All
|
||||
with_confirmed_hide: Confirmed
|
||||
without_confirmed_hide: Pending
|
||||
users:
|
||||
index:
|
||||
title: Banned users
|
||||
@@ -73,6 +75,7 @@ en:
|
||||
filters:
|
||||
all: All
|
||||
with_confirmed_hide: Confirmed
|
||||
without_confirmed_hide: Pending
|
||||
show:
|
||||
title: "User activity from %{user}"
|
||||
back: Back
|
||||
|
||||
@@ -59,6 +59,7 @@ es:
|
||||
filters:
|
||||
all: Todos
|
||||
with_confirmed_hide: Confirmados
|
||||
without_confirmed_hide: Pendientes
|
||||
debates:
|
||||
index:
|
||||
title: Debates ocultos
|
||||
@@ -66,6 +67,7 @@ es:
|
||||
filters:
|
||||
all: Todos
|
||||
with_confirmed_hide: Confirmados
|
||||
without_confirmed_hide: Pendientes
|
||||
users:
|
||||
index:
|
||||
title: Usuarios bloqueados
|
||||
@@ -73,6 +75,7 @@ es:
|
||||
filters:
|
||||
all: Todos
|
||||
with_confirmed_hide: Confirmados
|
||||
without_confirmed_hide: Pendientes
|
||||
show:
|
||||
title: "Actividad del usuario %{user}"
|
||||
back: Volver
|
||||
|
||||
@@ -34,6 +34,10 @@ module ActsAsParanoidAliases
|
||||
where("confirmed_hide_at IS NOT NULL")
|
||||
end
|
||||
|
||||
def without_confirmed_hide
|
||||
where("confirmed_hide_at IS NULL")
|
||||
end
|
||||
|
||||
def with_hidden
|
||||
with_deleted
|
||||
end
|
||||
|
||||
@@ -24,22 +24,31 @@ feature 'Admin comments' do
|
||||
|
||||
click_link 'Confirm'
|
||||
|
||||
expect(page).to_not have_content(comment.body)
|
||||
click_link('Confirmed')
|
||||
expect(page).to have_content(comment.body)
|
||||
expect(page).to have_content('Confirmed')
|
||||
|
||||
expect(comment.reload).to be_confirmed_hide
|
||||
end
|
||||
|
||||
scenario "Current filter is properly highlighted" do
|
||||
visit admin_comments_path
|
||||
expect(page).to_not have_link('All')
|
||||
expect(page).to_not have_link('Pending')
|
||||
expect(page).to have_link('All')
|
||||
expect(page).to have_link('Confirmed')
|
||||
|
||||
visit admin_comments_path(filter: 'Pending')
|
||||
expect(page).to_not have_link('Pending')
|
||||
expect(page).to have_link('All')
|
||||
expect(page).to have_link('Confirmed')
|
||||
|
||||
visit admin_comments_path(filter: 'all')
|
||||
expect(page).to have_link('Pending')
|
||||
expect(page).to_not have_link('All')
|
||||
expect(page).to have_link('Confirmed')
|
||||
|
||||
visit admin_comments_path(filter: 'with_confirmed_hide')
|
||||
expect(page).to have_link('Pending')
|
||||
expect(page).to have_link('All')
|
||||
expect(page).to_not have_link('Confirmed')
|
||||
end
|
||||
|
||||
@@ -24,23 +24,32 @@ feature 'Admin debates' do
|
||||
|
||||
click_link 'Confirm'
|
||||
|
||||
expect(page).to_not have_content(debate.title)
|
||||
click_link('Confirmed')
|
||||
expect(page).to have_content(debate.title)
|
||||
expect(page).to have_content('Confirmed')
|
||||
|
||||
expect(debate.reload).to be_confirmed_hide
|
||||
end
|
||||
|
||||
scenario "Current filter is properly highlighted" do
|
||||
visit admin_debates_path
|
||||
expect(page).to_not have_link('All')
|
||||
expect(page).to_not have_link('Pending')
|
||||
expect(page).to have_link('All')
|
||||
expect(page).to have_link('Confirmed')
|
||||
|
||||
visit admin_debates_path(filter: 'Pending')
|
||||
expect(page).to_not have_link('Pending')
|
||||
expect(page).to have_link('All')
|
||||
expect(page).to have_link('Confirmed')
|
||||
|
||||
visit admin_debates_path(filter: 'all')
|
||||
expect(page).to have_link('Pending')
|
||||
expect(page).to_not have_link('All')
|
||||
expect(page).to have_link('Confirmed')
|
||||
|
||||
visit admin_debates_path(filter: 'with_confirmed_hide')
|
||||
expect(page).to have_link('All')
|
||||
expect(page).to have_link('Pending')
|
||||
expect(page).to_not have_link('Confirmed')
|
||||
end
|
||||
|
||||
@@ -48,6 +57,10 @@ feature 'Admin debates' do
|
||||
create(:debate, :hidden, title: "Unconfirmed debate")
|
||||
create(:debate, :hidden, :with_confirmed_hide, title: "Confirmed debate")
|
||||
|
||||
visit admin_debates_path(filter: 'pending')
|
||||
expect(page).to have_content('Unconfirmed debate')
|
||||
expect(page).to_not have_content('Confirmed debate')
|
||||
|
||||
visit admin_debates_path(filter: 'all')
|
||||
expect(page).to have_content('Unconfirmed debate')
|
||||
expect(page).to have_content('Confirmed debate')
|
||||
|
||||
@@ -40,23 +40,32 @@ feature 'Admin users' do
|
||||
|
||||
click_link 'Confirm'
|
||||
|
||||
expect(page).to_not have_content(user.username)
|
||||
click_link('Confirmed')
|
||||
expect(page).to have_content(user.username)
|
||||
expect(page).to have_content('Confirmed')
|
||||
|
||||
expect(user.reload).to be_confirmed_hide
|
||||
end
|
||||
|
||||
scenario "Current filter is properly highlighted" do
|
||||
visit admin_users_path
|
||||
expect(page).to_not have_link('All')
|
||||
expect(page).to_not have_link('Pending')
|
||||
expect(page).to have_link('All')
|
||||
expect(page).to have_link('Confirmed')
|
||||
|
||||
visit admin_users_path(filter: 'Pending')
|
||||
expect(page).to_not have_link('Pending')
|
||||
expect(page).to have_link('All')
|
||||
expect(page).to have_link('Confirmed')
|
||||
|
||||
visit admin_users_path(filter: 'all')
|
||||
expect(page).to have_link('Pending')
|
||||
expect(page).to_not have_link('All')
|
||||
expect(page).to have_link('Confirmed')
|
||||
|
||||
visit admin_users_path(filter: 'with_confirmed_hide')
|
||||
expect(page).to have_link('All')
|
||||
expect(page).to have_link('Pending')
|
||||
expect(page).to_not have_link('Confirmed')
|
||||
end
|
||||
|
||||
|
||||
@@ -296,20 +296,13 @@ feature 'Debates' do
|
||||
end
|
||||
|
||||
describe 'Limiting tags shown' do
|
||||
tags = ["Hacienda", "Economía", "Medio Ambiente", "Corrupción", "Fiestas populares", "Prensa", "Huelgas"]
|
||||
let(:all_tags) { tags }
|
||||
let(:debate) { create :debate, tag_list: all_tags }
|
||||
|
||||
scenario 'Index page shows up to 5 tags per debate' do
|
||||
debate
|
||||
visible_tags = ["Medio Ambiente", "Corrupción", "Fiestas populares", "Prensa", "Huelgas"]
|
||||
tag_list = ["Hacienda", "Economía", "Medio Ambiente", "Corrupción", "Fiestas populares", "Prensa", "Huelgas"]
|
||||
create :debate, tag_list: tag_list
|
||||
|
||||
visit debates_path
|
||||
|
||||
within('.debate .tags') do
|
||||
visible_tags.each do |tag|
|
||||
expect(page).to have_content tag
|
||||
end
|
||||
expect(page).to have_content '2+'
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user