From 85722eb7c40ef4c859900be99370aba0573baea8 Mon Sep 17 00:00:00 2001 From: German Galia Date: Sun, 2 Jun 2019 19:12:26 +0200 Subject: [PATCH] Rename admin/debates and admin/comments to hidden --- .gitignore | 1 - ...oller.rb => hidden_comments_controller.rb} | 2 +- ...roller.rb => hidden_debates_controller.rb} | 4 +-- app/controllers/officing/base_controller.rb | 1 - app/helpers/admin_helper.rb | 2 +- app/views/admin/_menu.html.erb | 8 ++--- .../budget_investments/_investments.html.erb | 1 + .../index.html.erb | 13 ++++---- .../index.html.erb | 11 +++---- .../legislation/proposals/_geozones.html.erb | 2 +- app/views/stats/index.json.erb | 4 +-- config/environments/production.rb | 1 + config/i18n-tasks.yml | 6 ++-- config/locales/en/admin.yml | 4 +-- config/locales/es/admin.yml | 4 +-- config/routes/admin.rb | 4 +-- spec/factories/polls.rb | 1 - spec/features/admin/activity_spec.rb | 4 +-- spec/features/admin/comments_spec.rb | 30 +++++++++---------- spec/features/admin/debates_spec.rb | 22 +++++++------- 20 files changed, 63 insertions(+), 62 deletions(-) rename app/controllers/admin/{comments_controller.rb => hidden_comments_controller.rb} (92%) rename app/controllers/admin/{debates_controller.rb => hidden_debates_controller.rb} (91%) rename app/views/admin/{comments => hidden_comments}/index.html.erb (71%) rename app/views/admin/{debates => hidden_debates}/index.html.erb (78%) diff --git a/.gitignore b/.gitignore index 31491de9d..57284ee60 100644 --- a/.gitignore +++ b/.gitignore @@ -38,4 +38,3 @@ public/sitemap.xml public/system/ /public/ckeditor_assets/ - diff --git a/app/controllers/admin/comments_controller.rb b/app/controllers/admin/hidden_comments_controller.rb similarity index 92% rename from app/controllers/admin/comments_controller.rb rename to app/controllers/admin/hidden_comments_controller.rb index ef815470d..c3e3bdea9 100644 --- a/app/controllers/admin/comments_controller.rb +++ b/app/controllers/admin/hidden_comments_controller.rb @@ -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] diff --git a/app/controllers/admin/debates_controller.rb b/app/controllers/admin/hidden_debates_controller.rb similarity index 91% rename from app/controllers/admin/debates_controller.rb rename to app/controllers/admin/hidden_debates_controller.rb index bbe4a06d7..77d30b488 100644 --- a/app/controllers/admin/debates_controller.rb +++ b/app/controllers/admin/hidden_debates_controller.rb @@ -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 \ No newline at end of file +end diff --git a/app/controllers/officing/base_controller.rb b/app/controllers/officing/base_controller.rb index 96f185d24..42b85860b 100644 --- a/app/controllers/officing/base_controller.rb +++ b/app/controllers/officing/base_controller.rb @@ -45,5 +45,4 @@ class Officing::BaseController < ApplicationController def current_booth Poll::Booth.where(id: session[:booth_id]).first end - end diff --git a/app/helpers/admin_helper.rb b/app/helpers/admin_helper.rb index 0446aaf73..8f2c9c9cc 100644 --- a/app/helpers/admin_helper.rb +++ b/app/helpers/admin_helper.rb @@ -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 diff --git a/app/views/admin/_menu.html.erb b/app/views/admin/_menu.html.erb index cb509cf15..9745fcfbc 100644 --- a/app/views/admin/_menu.html.erb +++ b/app/views/admin/_menu.html.erb @@ -155,8 +155,8 @@ <% end %> <% if feature?(:debates) %> -
  • > - <%= link_to t("admin.menu.hidden_debates"), admin_debates_path %> +
  • > + <%= link_to t("admin.menu.hidden_debates"), admin_hidden_debates_path %>
  • <% end %> @@ -166,8 +166,8 @@ <% end %> -
  • > - <%= link_to t("admin.menu.hidden_comments"), admin_comments_path %> +
  • > + <%= link_to t("admin.menu.hidden_comments"), admin_hidden_comments_path %>
  • > diff --git a/app/views/admin/budget_investments/_investments.html.erb b/app/views/admin/budget_investments/_investments.html.erb index 55603bbcd..9f7f97735 100644 --- a/app/views/admin/budget_investments/_investments.html.erb +++ b/app/views/admin/budget_investments/_investments.html.erb @@ -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), diff --git a/app/views/admin/comments/index.html.erb b/app/views/admin/hidden_comments/index.html.erb similarity index 71% rename from app/views/admin/comments/index.html.erb rename to app/views/admin/hidden_comments/index.html.erb index adf27701e..28cabbcb5 100644 --- a/app/views/admin/comments/index.html.erb +++ b/app/views/admin/hidden_comments/index.html.erb @@ -1,7 +1,8 @@ -

    <%= t("admin.comments.index.title") %>

    +

    <%= t("admin.hidden_comments.index.title") %>

    <%= t("admin.shared.moderated_content") %>

    -<%= render "shared/filter_subnav", i18n_namespace: "admin.comments.index" %> + +<%= render "shared/filter_subnav", i18n_namespace: "admin.hidden_comments.index" %> <% if @comments.any? %>

    <%= page_entries_info @comments %>

    @@ -17,20 +18,20 @@ <%= text_with_links comment.body %>
    <% 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 %> <%= 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 %>
    - <%= t("admin.comments.index.no_hidden_comments") %> + <%= t("admin.hidden_comments.index.no_hidden_comments") %>
    <% end %> diff --git a/app/views/admin/debates/index.html.erb b/app/views/admin/hidden_debates/index.html.erb similarity index 78% rename from app/views/admin/debates/index.html.erb rename to app/views/admin/hidden_debates/index.html.erb index 45a992f3e..a11e821d9 100644 --- a/app/views/admin/debates/index.html.erb +++ b/app/views/admin/hidden_debates/index.html.erb @@ -1,7 +1,8 @@ -

    <%= t("admin.debates.index.title") %>

    +

    <%= t("admin.hidden_debates.index.title") %>

    <%= t("admin.shared.moderated_content") %>

    -<%= render "shared/filter_subnav", i18n_namespace: "admin.debates.index" %> + +<%= render "shared/filter_subnav", i18n_namespace: "admin.hidden_debates.index" %> <% if @debates.any? %>

    <%= page_entries_info @debates %>

    @@ -25,13 +26,13 @@ <%= 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 %>
    - <%= t("admin.debates.index.no_hidden_debates") %> + <%= t("admin.hidden_debates.index.no_hidden_debates") %>
    <% end %> diff --git a/app/views/legislation/proposals/_geozones.html.erb b/app/views/legislation/proposals/_geozones.html.erb index 064f819dd..4a8d8ee95 100644 --- a/app/views/legislation/proposals/_geozones.html.erb +++ b/app/views/legislation/proposals/_geozones.html.erb @@ -2,5 +2,5 @@
    <%= 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 %> diff --git a/app/views/stats/index.json.erb b/app/views/stats/index.json.erb index f997b4f31..c2c27702f 100644 --- a/app/views/stats/index.json.erb +++ b/app/views/stats/index.json.erb @@ -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) %>" -} \ No newline at end of file +} diff --git a/config/environments/production.rb b/config/environments/production.rb index 2972eb78f..49ffa3202 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -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 diff --git a/config/i18n-tasks.yml b/config/i18n-tasks.yml index c4c4b55e6..62617119d 100644 --- a/config/i18n-tasks.yml +++ b/config/i18n-tasks.yml @@ -131,9 +131,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*" @@ -149,7 +149,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" diff --git a/config/locales/en/admin.yml b/config/locales/en/admin.yml index c03001722..2263fe734 100644 --- a/config/locales/en/admin.yml +++ b/config/locales/en/admin.yml @@ -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: diff --git a/config/locales/es/admin.yml b/config/locales/es/admin.yml index 0e6a91fc0..492c0b15b 100644 --- a/config/locales/es/admin.yml +++ b/config/locales/es/admin.yml @@ -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: diff --git a/config/routes/admin.rb b/config/routes/admin.rb index 917f1447c..40a5765a0 100644 --- a/config/routes/admin.rb +++ b/config/routes/admin.rb @@ -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 @@ -83,7 +83,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 diff --git a/spec/factories/polls.rb b/spec/factories/polls.rb index b7a532d82..7b49d3f5a 100644 --- a/spec/factories/polls.rb +++ b/spec/factories/polls.rb @@ -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) diff --git a/spec/features/admin/activity_spec.rb b/spec/features/admin/activity_spec.rb index 113062427..891e59947 100644 --- a/spec/features/admin/activity_spec.rb +++ b/spec/features/admin/activity_spec.rb @@ -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" diff --git a/spec/features/admin/comments_spec.rb b/spec/features/admin/comments_spec.rb index 5953e5252..7806df96e 100644 --- a/spec/features/admin/comments_spec.rb +++ b/spec/features/admin/comments_spec.rb @@ -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 \ No newline at end of file +end diff --git a/spec/features/admin/debates_spec.rb b/spec/features/admin/debates_spec.rb index 009e1900e..2b3e683c0 100644 --- a/spec/features/admin/debates_spec.rb +++ b/spec/features/admin/debates_spec.rb @@ -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)