Skip to content

Commit

Permalink
Legislation proposals show and edit views available
Browse files Browse the repository at this point in the history
  • Loading branch information
MariaCheca committed Sep 20, 2017
1 parent c1672bd commit 38ba5e1
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 19 deletions.
4 changes: 0 additions & 4 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,6 @@ def set_proposal_votes(proposals)
@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
Expand Down
4 changes: 4 additions & 0 deletions app/controllers/legislation/base_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions app/controllers/legislation/processes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ def proposals
@phase = :proposals_phase

if @process.proposals_phase.started?
set_legislation_proposal_votes(@process.proposals)
render :proposals
else
render :phase_not_open
Expand Down
11 changes: 6 additions & 5 deletions app/controllers/legislation/proposals_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -79,18 +80,18 @@ def summary
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

Expand All @@ -102,7 +103,7 @@ def resource_name
'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

Expand Down
4 changes: 2 additions & 2 deletions app/views/legislation/proposals/_proposal.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
<div class="small-12 medium-9 column">
<div class="proposal-content">
<% cache [locale_and_user_status(proposal), 'index', proposal, proposal.author] do %>
<h3><%= link_to proposal.title, namespaced_proposal_path(proposal) %></h3>
<h3><%= link_to proposal.title, legislation_process_proposal_path(proposal.legislation_process_id, proposal) %></h3>
<p class="proposal-info">
<span class="icon-comments"></span>&nbsp;
<%= 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") %>

<span class="bullet">&nbsp;&bull;&nbsp;</span>
<%= l proposal.created_at.to_date %>
Expand Down
4 changes: 2 additions & 2 deletions app/views/legislation/proposals/_votes.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
</span>

<div class="in-favor">
<% if voted_for?(@proposal_votes, proposal) %>
<% if voted_for?(@legislation_proposal_votes, proposal) %>
<div class="supported callout success">
<%= t("proposals.proposal.already_supported") %>
</div>
Expand Down Expand Up @@ -58,7 +58,7 @@
</div>
<% end %>
<% if voted_for?(@proposal_votes, proposal) && setting['twitter_handle'] %>
<% if voted_for?(@legislation_proposal_votes, proposal) && setting['twitter_handle'] %>
<div class="share-supported">
<%= social_share_button_tag("#{proposal.title} #{setting['twitter_hashtag']}", url: proposal_url(proposal), via: setting['twitter_handle']) %>
</div>
Expand Down
4 changes: 2 additions & 2 deletions app/views/legislation/proposals/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
<%= back_link_to %>

<div class="float-right">
<%= link_to t("proposals.edit.show_link"), @proposal %>
<%= link_to t("proposals.edit.show_link"), legislation_process_proposal_path(@proposal.legislation_process_id, @proposal) %>
</div>

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

<%= render "form", form_url: proposal_url(@proposal) %>
<%= render "form", form_url: legislation_process_proposal_url(@proposal.legislation_process_id, @proposal) %>
</div>
</div>
2 changes: 1 addition & 1 deletion app/views/legislation/proposals/share.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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 %>
<div class="proposal-show">
<div id="<%= dom_id(@proposal) %>" class="row">
<div class="small-12 medium-8 column">
Expand Down
6 changes: 3 additions & 3 deletions app/views/legislation/proposals/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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 %>
<div class="proposal-show">
<div id="<%= dom_id(@proposal) %>" class="row">
<div class="small-12 medium-9 column">
Expand All @@ -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 %>
Expand Down Expand Up @@ -147,7 +147,7 @@
</div>
<% 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 %>
</div>
<%= render partial: 'shared/social_share', locals: {
Expand Down

0 comments on commit 38ba5e1

Please sign in to comment.