diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 318777314..495a25314 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -76,10 +76,6 @@ class ApplicationController < ActionController::Base @proposal_votes = current_user ? current_user.proposal_votes(proposals) : {} end - def set_legislation_proposal_votes(proposals) - @proposal_votes = current_user ? current_user.legislation_proposal_votes(proposals) : {} - end - def set_spending_proposal_votes(spending_proposals) @spending_proposal_votes = current_user ? current_user.spending_proposal_votes(spending_proposals) : {} end diff --git a/app/controllers/legislation/base_controller.rb b/app/controllers/legislation/base_controller.rb index ca609ecba..c08ffc444 100644 --- a/app/controllers/legislation/base_controller.rb +++ b/app/controllers/legislation/base_controller.rb @@ -2,4 +2,8 @@ class Legislation::BaseController < ApplicationController include FeatureFlags feature_flag :legislation + + def set_legislation_proposal_votes(proposals) + @legislation_proposal_votes = current_user ? current_user.legislation_proposal_votes(proposals) : {} + end end diff --git a/app/controllers/legislation/processes_controller.rb b/app/controllers/legislation/processes_controller.rb index 6c12cea5b..d788d3bf3 100644 --- a/app/controllers/legislation/processes_controller.rb +++ b/app/controllers/legislation/processes_controller.rb @@ -88,6 +88,7 @@ class Legislation::ProcessesController < Legislation::BaseController @phase = :proposals_phase if @process.proposals_phase.started? + set_legislation_proposal_votes(@process.proposals) render :proposals else render :phase_not_open diff --git a/app/controllers/legislation/proposals_controller.rb b/app/controllers/legislation/proposals_controller.rb index 1eab07047..c65315ddf 100644 --- a/app/controllers/legislation/proposals_controller.rb +++ b/app/controllers/legislation/proposals_controller.rb @@ -20,6 +20,7 @@ class Legislation::ProposalsController < Legislation::BaseController def show super + set_legislation_proposal_votes(@process.proposals) @notifications = @proposal.notifications @document = Document.new(documentable: @proposal) redirect_to legislation_process_proposal_path(params[:process_id], @proposal), @@ -79,18 +80,18 @@ class Legislation::ProposalsController < Legislation::BaseController private def proposal_params - params.require(:proposal).permit(:legislation_process_id, :title, :question, :summary, :description, :external_url, :video_url, + params.require(:legislation_proposal).permit(:legislation_process_id, :title, :question, :summary, :description, :external_url, :video_url, :responsible_name, :tag_list, :terms_of_service, :geozone_id, documents_attributes: [:id, :title, :attachment, :cached_attachment, :user_id] ) end def retired_params - params.require(:proposal).permit(:retired_reason, :retired_explanation) + params.require(:legislation_proposal).permit(:retired_reason, :retired_explanation) end def valid_retired_params? - @proposal.errors.add(:retired_reason, I18n.t('errors.messages.blank')) if params[:proposal][:retired_reason].blank? - @proposal.errors.add(:retired_explanation, I18n.t('errors.messages.blank')) if params[:proposal][:retired_explanation].blank? + @proposal.errors.add(:retired_reason, I18n.t('errors.messages.blank')) if params[:legislation_proposal][:retired_reason].blank? + @proposal.errors.add(:retired_explanation, I18n.t('errors.messages.blank')) if params[:legislation_proposal][:retired_explanation].blank? @proposal.errors.empty? end @@ -102,7 +103,7 @@ class Legislation::ProposalsController < Legislation::BaseController 'proposal' end - def set_legislation_proposal_votes(proposals) + def set_featured_proposal_votes(proposals) @featured_proposals_votes = current_user ? current_user.proposal_votes(proposals) : {} end diff --git a/app/views/legislation/proposals/_proposal.html.erb b/app/views/legislation/proposals/_proposal.html.erb index 996be8f95..f3b603aa5 100644 --- a/app/views/legislation/proposals/_proposal.html.erb +++ b/app/views/legislation/proposals/_proposal.html.erb @@ -8,10 +8,10 @@
<% cache [locale_and_user_status(proposal), 'index', proposal, proposal.author] do %> -

<%= link_to proposal.title, namespaced_proposal_path(proposal) %>

+

<%= link_to proposal.title, legislation_process_proposal_path(proposal.legislation_process_id, proposal) %>

  - <%= link_to t("proposals.proposal.comments", count: proposal.comments_count), namespaced_proposal_path(proposal, anchor: "comments") %> + <%= link_to t("proposals.proposal.comments", count: proposal.comments_count), legislation_process_proposal_path(proposal.legislation_process_id, proposal, anchor: "comments") %>  •  <%= l proposal.created_at.to_date %> diff --git a/app/views/legislation/proposals/_votes.html.erb b/app/views/legislation/proposals/_votes.html.erb index fb41357af..b44c4d6cb 100644 --- a/app/views/legislation/proposals/_votes.html.erb +++ b/app/views/legislation/proposals/_votes.html.erb @@ -16,7 +16,7 @@

- <% if voted_for?(@proposal_votes, proposal) %> + <% if voted_for?(@legislation_proposal_votes, proposal) %>
<%= t("proposals.proposal.already_supported") %>
@@ -58,7 +58,7 @@
<% end %> - <% if voted_for?(@proposal_votes, proposal) && setting['twitter_handle'] %> + <% if voted_for?(@legislation_proposal_votes, proposal) && setting['twitter_handle'] %> diff --git a/app/views/legislation/proposals/edit.html.erb b/app/views/legislation/proposals/edit.html.erb index 6e5b14a08..6d4761524 100644 --- a/app/views/legislation/proposals/edit.html.erb +++ b/app/views/legislation/proposals/edit.html.erb @@ -4,11 +4,11 @@ <%= back_link_to %>
- <%= link_to t("proposals.edit.show_link"), @proposal %> + <%= link_to t("proposals.edit.show_link"), legislation_process_proposal_path(@proposal.legislation_process_id, @proposal) %>

<%= t("proposals.edit.editing") %>

- <%= render "form", form_url: proposal_url(@proposal) %> + <%= render "form", form_url: legislation_process_proposal_url(@proposal.legislation_process_id, @proposal) %>
diff --git a/app/views/legislation/proposals/share.html.erb b/app/views/legislation/proposals/share.html.erb index 5faa9d985..8ea0f7e98 100644 --- a/app/views/legislation/proposals/share.html.erb +++ b/app/views/legislation/proposals/share.html.erb @@ -9,7 +9,7 @@ <%= render "shared/canonical", href: proposal_url(@proposal) %> <% end %> -<% cache [locale_and_user_status(@proposal), @proposal, @proposal.author, Flag.flagged?(current_user, @proposal), @proposal_votes] do %> +<% cache [locale_and_user_status(@proposal), @proposal, @proposal.author, Flag.flagged?(current_user, @proposal), @legislation_proposal_votes] do %>
diff --git a/app/views/legislation/proposals/show.html.erb b/app/views/legislation/proposals/show.html.erb index 1dc918e8e..b17464a04 100644 --- a/app/views/legislation/proposals/show.html.erb +++ b/app/views/legislation/proposals/show.html.erb @@ -10,7 +10,7 @@ <%= render "shared/canonical", href: proposal_url(@proposal) %> <% end %> -<% cache [locale_and_user_status(@proposal), @proposal, @proposal.author, Flag.flagged?(current_user, @proposal), @proposal_votes] do %> +<% cache [locale_and_user_status(@proposal), @proposal, @proposal.author, Flag.flagged?(current_user, @proposal), @legislation_proposal_votes] do %>
@@ -29,7 +29,7 @@ <% end %> <% if current_user && @proposal.editable_by?(current_user) %> - <%= link_to edit_proposal_path(@proposal), class: 'edit-proposal button hollow float-right' do %> + <%= link_to edit_legislation_process_proposal_path(@proposal.legislation_process_id, @proposal), class: 'edit-proposal button hollow float-right' do %> <%= t("proposals.show.edit_proposal_link") %> <% end %> <% end %> @@ -147,7 +147,7 @@
<% else %> <%= render 'votes', - { proposal: @proposal, vote_url: vote_proposal_path(@proposal, value: 'yes') } %> + { proposal: @proposal, vote_url: vote_legislation_process_proposal_path(@proposal.legislation_process_id, @proposal, value: 'yes') } %> <% end %>
<%= render partial: 'shared/social_share', locals: {