From 0bacd5baf3ca3dd913fb1ebccfda1d1fc7abbec1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Tue, 28 Sep 2021 18:45:31 +0200 Subject: [PATCH] Remove unused legislation proposals index action The `legislation_proposals#index` action was never used because it used the same URL as `legislation_processes#proposals`. In commit 702bfec24 we removed the view, but we forgot to remove the controller action, the route, and some partials which were rendered from the index view. --- .../legislation/proposals_controller.rb | 14 +----- app/models/abilities/common.rb | 1 - .../proposals/_featured_proposal.html.erb | 27 ------------ .../proposals/_featured_votes.html.erb | 43 ------------------- .../legislation/proposals/_geozones.html.erb | 6 --- .../legislation/proposals/_popular.html.erb | 6 --- config/locales/en/general.yml | 1 - config/locales/es/general.yml | 1 - config/routes/legislation.rb | 2 +- 9 files changed, 3 insertions(+), 98 deletions(-) delete mode 100644 app/views/legislation/proposals/_featured_proposal.html.erb delete mode 100644 app/views/legislation/proposals/_featured_votes.html.erb delete mode 100644 app/views/legislation/proposals/_geozones.html.erb delete mode 100644 app/views/legislation/proposals/_popular.html.erb diff --git a/app/controllers/legislation/proposals_controller.rb b/app/controllers/legislation/proposals_controller.rb index 10ffdf44a..d924f43ec 100644 --- a/app/controllers/legislation/proposals_controller.rb +++ b/app/controllers/legislation/proposals_controller.rb @@ -3,16 +3,15 @@ class Legislation::ProposalsController < Legislation::BaseController include FlagActions include ImageAttributes - before_action :load_categories, only: [:index, :new, :create, :edit, :map, :summary] + before_action :load_categories, only: [:new, :create, :edit, :map, :summary] before_action :load_geozones, only: [:edit, :map, :summary] - before_action :authenticate_user!, except: [:index, :show, :map, :summary] + before_action :authenticate_user!, except: [:show, :map, :summary] load_and_authorize_resource :process, class: "Legislation::Process" load_and_authorize_resource :proposal, class: "Legislation::Proposal", through: :process invisible_captcha only: [:create, :update], honeypot: :subtitle - has_orders %w[confidence_score created_at], only: :index has_orders %w[most_voted newest oldest], only: :show helper_method :resource_model, :resource_name @@ -38,11 +37,6 @@ class Legislation::ProposalsController < Legislation::BaseController end end - def index_customization - load_successful_proposals - load_featured unless @proposal_successful_exists - end - def vote @proposal.register_vote(current_user, params[:value]) legislation_proposal_votes(@proposal) @@ -65,8 +59,4 @@ class Legislation::ProposalsController < Legislation::BaseController def resource_name "proposal" end - - def load_successful_proposals - @proposal_successful_exists = Legislation::Proposal.successful.exists? - end end diff --git a/app/models/abilities/common.rb b/app/models/abilities/common.rb index ce55d8734..da8fa7197 100644 --- a/app/models/abilities/common.rb +++ b/app/models/abilities/common.rb @@ -88,7 +88,6 @@ module Abilities can :vote_featured, Proposal can :vote, Legislation::Proposal - can :vote_featured, Legislation::Proposal can :create, Legislation::Answer can :create, Budget::Investment, budget: { phase: "accepting" } diff --git a/app/views/legislation/proposals/_featured_proposal.html.erb b/app/views/legislation/proposals/_featured_proposal.html.erb deleted file mode 100644 index 4733f3488..000000000 --- a/app/views/legislation/proposals/_featured_proposal.html.erb +++ /dev/null @@ -1,27 +0,0 @@ - diff --git a/app/views/legislation/proposals/_featured_votes.html.erb b/app/views/legislation/proposals/_featured_votes.html.erb deleted file mode 100644 index 4c42406b0..000000000 --- a/app/views/legislation/proposals/_featured_votes.html.erb +++ /dev/null @@ -1,43 +0,0 @@ -
-
- <% if voted_for?(@featured_proposals_votes, proposal) %> -
- <%= t("proposals.proposal.already_supported") %> -
- <% else %> - <%= link_to vote_featured_proposal_path(proposal, value: "yes"), - class: "button button-support small expanded", - title: t("proposals.proposal.support_title"), method: "post", remote: true do %> - <%= t("proposals.proposal.support") %> - <% end %> - <% end %> -
- - <% if user_signed_in? && current_user.organization? %> - - <% elsif user_signed_in? && !proposal.votable_by?(current_user) %> - - <% elsif !user_signed_in? %> - <%= render "shared/login_to_vote" %> - <% end %> - - <% if voted_for?(@featured_proposals_votes, proposal) %> - <% if setting["twitter_handle"] %> - - <% end %> - <% end %> -
diff --git a/app/views/legislation/proposals/_geozones.html.erb b/app/views/legislation/proposals/_geozones.html.erb deleted file mode 100644 index 4a8d8ee95..000000000 --- a/app/views/legislation/proposals/_geozones.html.erb +++ /dev/null @@ -1,6 +0,0 @@ - - -
-<%= 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"))) %> -<% end %> diff --git a/app/views/legislation/proposals/_popular.html.erb b/app/views/legislation/proposals/_popular.html.erb deleted file mode 100644 index 7f46ea802..000000000 --- a/app/views/legislation/proposals/_popular.html.erb +++ /dev/null @@ -1,6 +0,0 @@ - - - -

- <%= link_to t("proposals.index.top_link_proposals"), summary_proposals_path, class: "small" %>
-

diff --git a/config/locales/en/general.yml b/config/locales/en/general.yml index 6758c457c..c6f99722b 100644 --- a/config/locales/en/general.yml +++ b/config/locales/en/general.yml @@ -376,7 +376,6 @@ en: select_order_long: "You are viewing proposals according to:" start_proposal: Create a proposal title: Proposals - top: Top weekly top_link_proposals: The most supported proposals by category section_header: icon_alt: Proposals icon diff --git a/config/locales/es/general.yml b/config/locales/es/general.yml index e802f7178..aaae524ca 100644 --- a/config/locales/es/general.yml +++ b/config/locales/es/general.yml @@ -376,7 +376,6 @@ es: select_order_long: "Estas viendo las propuestas" start_proposal: Crea una propuesta title: Propuestas ciudadanas - top: Top semanal top_link_proposals: Propuestas más apoyadas por categoría section_header: icon_alt: Icono de Propuestas diff --git a/config/routes/legislation.rb b/config/routes/legislation.rb index ee92ce26c..0a06ad511 100644 --- a/config/routes/legislation.rb +++ b/config/routes/legislation.rb @@ -14,7 +14,7 @@ namespace :legislation do resources :answers, only: [:create] end - resources :proposals do + resources :proposals, except: [:index] do member do post :vote put :flag