Merge pull request #3376 from LextrendIT/3350_rename_debates_comments_admin

Refactor admin/debates and admin/comments to hidden
This commit is contained in:
Javier Martín
2019-06-05 19:15:21 +02:00
committed by GitHub
20 changed files with 63 additions and 62 deletions

1
.gitignore vendored
View File

@@ -38,4 +38,3 @@
public/sitemap.xml
public/system/
/public/ckeditor_assets/

View File

@@ -1,4 +1,4 @@
class Admin::CommentsController < Admin::BaseController
class Admin::HiddenCommentsController < Admin::BaseController
has_filters %w{without_confirmed_hide all with_confirmed_hide}
before_action :load_comment, only: [:confirm_hide, :restore]

View File

@@ -1,4 +1,4 @@
class Admin::DebatesController < Admin::BaseController
class Admin::HiddenDebatesController < Admin::BaseController
include FeatureFlags
feature_flag :debates
@@ -29,4 +29,4 @@ class Admin::DebatesController < Admin::BaseController
@debate = Debate.with_hidden.find(params[:id])
end
end
end

View File

@@ -45,5 +45,4 @@ class Officing::BaseController < ApplicationController
def current_booth
Poll::Booth.where(id: session[:booth_id]).first
end
end

View File

@@ -25,7 +25,7 @@ module AdminHelper
end
def moderated_sections
["hidden_proposals", "debates", "comments", "hidden_users", "activity",
["hidden_proposals", "hidden_debates", "hidden_comments", "hidden_users", "activity",
"hidden_budget_investments"]
end

View File

@@ -141,8 +141,8 @@
<% end %>
<% if feature?(:debates) %>
<li <%= "class=is-active" if controller_name == "debates" %>>
<%= link_to t("admin.menu.hidden_debates"), admin_debates_path %>
<li <%= "class=is-active" if controller_name == "hidden_debates" %>>
<%= link_to t("admin.menu.hidden_debates"), admin_hidden_debates_path %>
</li>
<% end %>
@@ -152,8 +152,8 @@
</li>
<% end %>
<li <%= "class=is-active" if controller_name == "comments" %>>
<%= link_to t("admin.menu.hidden_comments"), admin_comments_path %>
<li <%= "class=is-active" if controller_name == "hidden_comments" %>>
<%= link_to t("admin.menu.hidden_comments"), admin_hidden_comments_path %>
</li>
<li <%= "class=is-active" if controller_name == "proposal_notifications" %>>

View File

@@ -2,6 +2,7 @@
admin_budget_budget_investments_path(csv_params),
class: "float-right small clear" %>
<% if params[:advanced_filters].include?("winners") %>
<% if display_calculate_winners_button?(@budget) %>
<%= link_to calculate_winner_button_text(@budget),

View File

@@ -1,7 +1,8 @@
<h2><%= t("admin.comments.index.title") %></h2>
<h2><%= t("admin.hidden_comments.index.title") %></h2>
<p><%= t("admin.shared.moderated_content") %></p>
<%= render "shared/filter_subnav", i18n_namespace: "admin.comments.index" %>
<%= render "shared/filter_subnav", i18n_namespace: "admin.hidden_comments.index" %>
<% if @comments.any? %>
<h3 class="margin"><%= page_entries_info @comments %></h3>
@@ -17,20 +18,20 @@
<td>
<%= text_with_links comment.body %><br>
<% if comment.commentable.hidden? %>
(<%= t("admin.comments.index.hidden_#{comment.commentable_type.downcase}") %>: <%= comment.commentable.title %>)
(<%= t("admin.hidden_comments.index.hidden_#{comment.commentable_type.downcase}") %>: <%= comment.commentable.title %>)
<% else %>
<%= link_to comment.commentable.title, commentable_path(comment) %>
<% end %>
</td>
<td>
<%= link_to t("admin.actions.restore"),
restore_admin_comment_path(comment, request.query_parameters),
restore_admin_hidden_comment_path(comment, request.query_parameters),
method: :put,
data: { confirm: t("admin.actions.confirm") },
class: "button hollow warning" %>
<% unless comment.confirmed_hide? %>
<%= link_to t("admin.actions.confirm_hide"),
confirm_hide_admin_comment_path(comment, request.query_parameters),
confirm_hide_admin_hidden_comment_path(comment, request.query_parameters),
method: :put,
class: "button" %>
<% end %>
@@ -43,6 +44,6 @@
<%= paginate @comments %>
<% else %>
<div class="callout primary margin">
<%= t("admin.comments.index.no_hidden_comments") %>
<%= t("admin.hidden_comments.index.no_hidden_comments") %>
</div>
<% end %>

View File

@@ -1,7 +1,8 @@
<h2><%= t("admin.debates.index.title") %></h2>
<h2><%= t("admin.hidden_debates.index.title") %></h2>
<p><%= t("admin.shared.moderated_content") %></p>
<%= render "shared/filter_subnav", i18n_namespace: "admin.debates.index" %>
<%= render "shared/filter_subnav", i18n_namespace: "admin.hidden_debates.index" %>
<% if @debates.any? %>
<h3 class="margin"><%= page_entries_info @debates %></h3>
@@ -25,13 +26,13 @@
</td>
<td class="align-top">
<%= link_to t("admin.actions.restore"),
restore_admin_debate_path(debate, request.query_parameters),
restore_admin_hidden_debate_path(debate, request.query_parameters),
method: :put,
data: { confirm: t("admin.actions.confirm") },
class: "button hollow warning" %>
<% unless debate.confirmed_hide? %>
<%= link_to t("admin.actions.confirm_hide"),
confirm_hide_admin_debate_path(debate, request.query_parameters),
confirm_hide_admin_hidden_debate_path(debate, request.query_parameters),
method: :put,
class: "button" %>
<% end %>
@@ -44,6 +45,6 @@
<%= paginate @debates %>
<% else %>
<div class="callout primary margin">
<%= t("admin.debates.index.no_hidden_debates") %>
<%= t("admin.hidden_debates.index.no_hidden_debates") %>
</div>
<% end %>

View File

@@ -2,5 +2,5 @@
<h2 class="sidebar-title"><%= t("shared.tags_cloud.districts") %></h2>
<br>
<%= link_to map_proposals_path, id: "map", title: t("shared.tags_cloud.districts_list") do %>
<%= image_tag(image_path_for("map.jpg", alt: t("shared.tags_cloud.districts_list")) %>
<%= image_tag(image_path_for("map.jpg", alt: t("shared.tags_cloud.districts_list"))) %>
<% end %>

View File

@@ -1,6 +1,6 @@
{
"<%= t("stats.index.visits") %>" : "<%= number_with_delimiter(@visits) %>",
"<%= t("stats.index.debates") %>" : <%= number_with_delimiter(@debates) %>",
"<%= t("stats.index.debates") %>" : "<%= number_with_delimiter(@debates) %>",
"<%= t("stats.index.proposals") %>" : "<%= number_with_delimiter(@proposals) %>",
"<%= t("stats.index.comments") %>" : "<%= number_with_delimiter(@comments) %>",
"<%= t("stats.index.proposal_votes") %>" : "<%= number_with_delimiter(@proposal_votes) %>",
@@ -9,4 +9,4 @@
"<%= t("stats.index.votes") %>" : "<%= number_with_delimiter(@votes) %>",
"<%= t("stats.index.verified_users") %>" : "<%= number_with_delimiter(@verified_users) %>",
"<%= t("stats.index.unverified_users") %>" : "<%= number_with_delimiter(@unverified_users) %>"
}
}

View File

@@ -48,6 +48,7 @@ Rails.application.configure do
# config.action_cable.url = 'wss://example.com/cable'
# config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ]
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
config.force_ssl = true

View File

@@ -133,9 +133,9 @@ ignore_unused:
- "date.order"
- "unauthorized.*"
- "admin.officials.level_*"
- "admin.comments.index.filter*"
- "admin.hidden_comments.index.filter*"
- "admin.banners.index.filters.*"
- "admin.debates.index.filter*"
- "admin.hidden_debates.index.filter*"
- "admin.hidden_proposals.index.filter*"
- "admin.proposal_notifications.index.filter*"
- "admin.budgets.index.filter*"
@@ -150,7 +150,7 @@ ignore_unused:
- "admin.legislation.processes.proposals.select_order"
- "admin.legislation.draft_versions.*.submit_button"
- "admin.legislation.questions.*.submit_button"
- "admin.comments.index.hidden_*"
- "admin.hidden_comments.index.hidden_*"
- "admin.settings.index.features.*"
- "admin.polls.*.submit_button"
- "admin.booths.*.submit_button"

View File

@@ -355,7 +355,7 @@ en:
notice: "Progress bar updated successfully"
delete:
notice: "Progress bar deleted successfully"
comments:
hidden_comments:
index:
filter: Filter
filters:
@@ -430,7 +430,7 @@ en:
request: Requested resource
update:
success: The task has been marked as solved.
debates:
hidden_debates:
index:
filter: Filter
filters:

View File

@@ -355,7 +355,7 @@ es:
notice: "Barra de progreso actualizada"
delete:
notice: "Barra de progreso eliminada correctamente"
comments:
hidden_comments:
index:
filter: Filtro
filters:
@@ -430,7 +430,7 @@ es:
request: Recurso solicitado
update:
success: La tarea ha sido marcada como resuelta
debates:
hidden_debates:
index:
filter: Filtro
filters:

View File

@@ -22,7 +22,7 @@ namespace :admin do
end
end
resources :debates, only: :index do
resources :hidden_debates, only: :index do
member do
put :restore
put :confirm_hide
@@ -75,7 +75,7 @@ namespace :admin do
collection { get :search }
end
resources :comments, only: :index do
resources :hidden_comments, only: :index do
member do
put :restore
put :confirm_hide

View File

@@ -94,7 +94,6 @@ FactoryBot.define do
transient { budget nil }
poll { budget&.poll || association(:poll, budget: budget) }
trait :from_web do
origin "web"
token SecureRandom.hex(32)

View File

@@ -117,7 +117,7 @@ describe "Admin activity" do
scenario "Shows admin restores" do
debate = create(:debate, :hidden)
visit admin_debates_path
visit admin_hidden_debates_path
within("#debate_#{debate.id}") do
click_on "Restore"
@@ -181,7 +181,7 @@ describe "Admin activity" do
scenario "Shows admin restores" do
comment = create(:comment, :hidden)
visit admin_comments_path
visit admin_hidden_comments_path
within("#comment_#{comment.id}") do
click_on "Restore"

View File

@@ -12,7 +12,7 @@ describe "Admin comments" do
proposal = create(:proposal, author: comment.author)
create(:comment, commentable: proposal, user: comment.author, body: "Good Proposal!")
visit admin_comments_path
visit admin_hidden_comments_path
expect(page).to have_content("SPAM from SPAMMER")
expect(page).not_to have_content("Good Proposal!")
@@ -21,7 +21,7 @@ describe "Admin comments" do
click_link "Hide author"
end
visit admin_comments_path
visit admin_hidden_comments_path
expect(page).not_to have_content("SPAM from SPAMMER")
expect(page).not_to have_content("Good Proposal!")
end
@@ -32,7 +32,7 @@ describe "Admin comments" do
create(:comment, :hidden, commentable: debate, body: "This is SPAM comment on debate")
create(:comment, :hidden, commentable: proposal, body: "This is SPAM comment on proposal")
visit admin_comments_path
visit admin_hidden_comments_path
expect(page).to have_content("Debate with spam comment")
expect(page).to have_content("Proposal with spam comment")
@@ -43,7 +43,7 @@ describe "Admin comments" do
expect(page).to have_content("Debate with spam comment")
expect(page).not_to have_content("This is SPAM comment on debate")
visit admin_comments_path
visit admin_hidden_comments_path
click_link "Proposal with spam comment"
expect(page).to have_content("Proposal with spam comment")
@@ -56,7 +56,7 @@ describe "Admin comments" do
create(:comment, :hidden, commentable: debate, body: "This is SPAM comment on debate")
create(:comment, :hidden, commentable: proposal, body: "This is SPAM comment on proposal")
visit admin_comments_path
visit admin_hidden_comments_path
expect(page).to have_content("(Hidden proposal: Hidden proposal title)")
expect(page).to have_content("(Hidden debate: Hidden debate title)")
@@ -67,7 +67,7 @@ describe "Admin comments" do
scenario "Restore" do
comment = create(:comment, :hidden, body: "Not really SPAM")
visit admin_comments_path
visit admin_hidden_comments_path
click_link "Restore"
@@ -79,7 +79,7 @@ describe "Admin comments" do
scenario "Confirm hide" do
comment = create(:comment, :hidden, body: "SPAM")
visit admin_comments_path
visit admin_hidden_comments_path
click_link "Confirm moderation"
@@ -91,22 +91,22 @@ describe "Admin comments" do
end
scenario "Current filter is properly highlighted" do
visit admin_comments_path
visit admin_hidden_comments_path
expect(page).not_to have_link("Pending")
expect(page).to have_link("All")
expect(page).to have_link("Confirmed")
visit admin_comments_path(filter: "Pending")
visit admin_hidden_comments_path(filter: "Pending")
expect(page).not_to have_link("Pending")
expect(page).to have_link("All")
expect(page).to have_link("Confirmed")
visit admin_comments_path(filter: "all")
visit admin_hidden_comments_path(filter: "all")
expect(page).to have_link("Pending")
expect(page).not_to have_link("All")
expect(page).to have_link("Confirmed")
visit admin_comments_path(filter: "with_confirmed_hide")
visit admin_hidden_comments_path(filter: "with_confirmed_hide")
expect(page).to have_link("Pending")
expect(page).to have_link("All")
expect(page).not_to have_link("Confirmed")
@@ -116,11 +116,11 @@ describe "Admin comments" do
create(:comment, :hidden, body: "Unconfirmed comment")
create(:comment, :hidden, :with_confirmed_hide, body: "Confirmed comment")
visit admin_comments_path(filter: "all")
visit admin_hidden_comments_path(filter: "all")
expect(page).to have_content("Unconfirmed comment")
expect(page).to have_content("Confirmed comment")
visit admin_comments_path(filter: "with_confirmed_hide")
visit admin_hidden_comments_path(filter: "with_confirmed_hide")
expect(page).not_to have_content("Unconfirmed comment")
expect(page).to have_content("Confirmed comment")
end
@@ -129,7 +129,7 @@ describe "Admin comments" do
per_page = Kaminari.config.default_per_page
(per_page + 2).times { create(:comment, :hidden, :with_confirmed_hide) }
visit admin_comments_path(filter: "with_confirmed_hide", page: 2)
visit admin_hidden_comments_path(filter: "with_confirmed_hide", page: 2)
click_on("Restore", match: :first, exact: true)
@@ -137,4 +137,4 @@ describe "Admin comments" do
expect(current_url).to include("page=2")
end
end
end

View File

@@ -7,7 +7,7 @@ describe "Admin debates" do
admin = create(:administrator)
login_as(admin.user)
expect{ visit admin_debates_path }.to raise_exception(FeatureFlags::FeatureDisabled)
expect{ visit admin_hidden_debates_path }.to raise_exception(FeatureFlags::FeatureDisabled)
Setting["process.debates"] = true
end
@@ -19,7 +19,7 @@ describe "Admin debates" do
scenario "Restore" do
debate = create(:debate, :hidden)
visit admin_debates_path
visit admin_hidden_debates_path
click_link "Restore"
@@ -31,7 +31,7 @@ describe "Admin debates" do
scenario "Confirm hide" do
debate = create(:debate, :hidden)
visit admin_debates_path
visit admin_hidden_debates_path
click_link "Confirm moderation"
@@ -43,22 +43,22 @@ describe "Admin debates" do
end
scenario "Current filter is properly highlighted" do
visit admin_debates_path
visit admin_hidden_debates_path
expect(page).not_to have_link("Pending")
expect(page).to have_link("All")
expect(page).to have_link("Confirmed")
visit admin_debates_path(filter: "Pending")
visit admin_hidden_debates_path(filter: "Pending")
expect(page).not_to have_link("Pending")
expect(page).to have_link("All")
expect(page).to have_link("Confirmed")
visit admin_debates_path(filter: "all")
visit admin_hidden_debates_path(filter: "all")
expect(page).to have_link("Pending")
expect(page).not_to have_link("All")
expect(page).to have_link("Confirmed")
visit admin_debates_path(filter: "with_confirmed_hide")
visit admin_hidden_debates_path(filter: "with_confirmed_hide")
expect(page).to have_link("All")
expect(page).to have_link("Pending")
expect(page).not_to have_link("Confirmed")
@@ -68,15 +68,15 @@ describe "Admin debates" do
create(:debate, :hidden, title: "Unconfirmed debate")
create(:debate, :hidden, :with_confirmed_hide, title: "Confirmed debate")
visit admin_debates_path(filter: "pending")
visit admin_hidden_debates_path(filter: "pending")
expect(page).to have_content("Unconfirmed debate")
expect(page).not_to have_content("Confirmed debate")
visit admin_debates_path(filter: "all")
visit admin_hidden_debates_path(filter: "all")
expect(page).to have_content("Unconfirmed debate")
expect(page).to have_content("Confirmed debate")
visit admin_debates_path(filter: "with_confirmed_hide")
visit admin_hidden_debates_path(filter: "with_confirmed_hide")
expect(page).not_to have_content("Unconfirmed debate")
expect(page).to have_content("Confirmed debate")
end
@@ -85,7 +85,7 @@ describe "Admin debates" do
per_page = Kaminari.config.default_per_page
(per_page + 2).times { create(:debate, :hidden, :with_confirmed_hide) }
visit admin_debates_path(filter: "with_confirmed_hide", page: 2)
visit admin_hidden_debates_path(filter: "with_confirmed_hide", page: 2)
click_on("Restore", match: :first, exact: true)