Adds links, texts and i18n

This commit is contained in:
Alberto Garcia Cabeza
2016-09-07 12:46:29 +02:00
parent a527de4f92
commit b107790039
8 changed files with 78 additions and 13 deletions

View File

@@ -28,6 +28,7 @@ class ProposalsController < ApplicationController
def index_customization def index_customization
load_retired load_retired
load_featured load_featured
load_proposal_ballots
end end
def vote def vote
@@ -97,4 +98,8 @@ class ProposalsController < ApplicationController
end end
end end
def load_proposal_ballots
@proposal_ballots = Proposal.successfull.sort_by_confidence_score
end
end end

View File

@@ -47,6 +47,7 @@ class Proposal < ActiveRecord::Base
scope :last_week, -> { where("proposals.created_at >= ?", 7.days.ago)} scope :last_week, -> { where("proposals.created_at >= ?", 7.days.ago)}
scope :retired, -> { where.not(retired_at: nil) } scope :retired, -> { where.not(retired_at: nil) }
scope :not_retired, -> { where(retired_at: nil) } scope :not_retired, -> { where(retired_at: nil) }
scope :successfull, -> { where("cached_votes_up + physical_votes >= ?", Proposal.votes_needed_for_success)}
def to_param def to_param
"#{id}-#{title}".parameterize "#{id}-#{title}".parameterize
@@ -155,6 +156,10 @@ class Proposal < ActiveRecord::Base
Setting['votes_for_proposal_success'].to_i Setting['votes_for_proposal_success'].to_i
end end
def successfull?
total_votes >= Proposal.votes_needed_for_success
end
def notifications def notifications
proposal_notifications proposal_notifications
end end

View File

@@ -1,10 +1,12 @@
<div id="<%= dom_id(proposal) %>" class="proposal clear" data-type="proposal"> <div id="<%= dom_id(proposal) %>"
class="proposal clear <%= ("successfull" if proposal.total_votes > Proposal.votes_needed_for_success) %>"
data-type="proposal">
<div class="panel"> <div class="panel">
<div class="icon-successfull"></div>
<div class="row"> <div class="row">
<div class="small-12 medium-9 column"> <div class="small-12 medium-9 column">
<div class="proposal-content"> <div class="proposal-content">
<% cache [locale_and_user_status(proposal), 'index', proposal, proposal.author] do %> <% cache [locale_and_user_status(proposal), 'index', proposal, proposal.author] do %>
<span class="label-proposal float-left"><%= t("proposals.proposal.proposal") %></span> <span class="label-proposal float-left"><%= t("proposals.proposal.proposal") %></span>
<span class="icon-proposals"></span> <span class="icon-proposals"></span>
@@ -50,11 +52,21 @@
</div> </div>
</div> </div>
<div id="<%= dom_id(proposal) %>_votes" class="small-12 medium-3 column text-center"> <div id="<%= dom_id(proposal) %>_votes" class="small-12 medium-3 column">
<%= render 'votes', <% if proposal.successfull? %>
{ proposal: proposal, vote_url: vote_proposal_path(proposal, value: 'yes') } %> <div class="message">
<p>
<%= t("proposal_ballots.successfull",
voting: link_to(t("proposal_ballots.voting"), proposal_ballots_path)).html_safe %>
</p>
</div>
<% else %>
<div class="text-center">
<%= render 'votes',
{ proposal: proposal, vote_url: vote_proposal_path(proposal, value: 'yes') } %>
</div>
<% end %>
</div> </div>
</div> </div>
</div> </div>
</div> </div>

View File

@@ -31,7 +31,19 @@
<%= render "shared/banner" %> <%= render "shared/banner" %>
<% end %> <% end %>
<% if @featured_proposals.present? %> <% if @proposal_ballots.present? %>
<div class="row featured-proposals-ballot">
<div class="small-12 column">
<div class="icon-successfull"></div>
<h2>
<%= t("proposal_ballots.featured_title") %>
</h2>
<% @proposal_ballots.each do |proposal_ballot| %>
<%= render "proposal_ballots/featured_successfull_proposal", proposal: proposal_ballot %>
<% end %>
</div>
</div>
<% elsif @featured_proposals.present? %>
<div id="featured-proposals" class="row featured-proposals"> <div id="featured-proposals" class="row featured-proposals">
<div class="small-12 column"> <div class="small-12 column">
<h2> <h2>

View File

@@ -102,12 +102,20 @@
<aside class="small-12 medium-3 column"> <aside class="small-12 medium-3 column">
<div class="sidebar-divider"></div> <div class="sidebar-divider"></div>
<h3><%= t("votes.supports") %></h3> <h3><%= t("votes.supports") %></h3>
<div class="text-center"> <% if @proposal.successfull? %>
<div id="<%= dom_id(@proposal) %>_votes"> <p>
<%= render 'votes', <%= t("proposal_ballots.successfull",
{ proposal: @proposal, vote_url: vote_proposal_path(@proposal, value: 'yes') } %> voting: link_to(t("proposal_ballots.voting"), proposal_ballots_path)).html_safe %>
</p>
<% else %>
<div class="text-center">
<div id="<%= dom_id(@proposal) %>_votes">
<%= render 'votes',
{ proposal: @proposal, vote_url: vote_proposal_path(@proposal, value: 'yes') } %>
</div>
</div> </div>
</div> <% end %>
<div id="social-share" class="sidebar-divider"></div> <div id="social-share" class="sidebar-divider"></div>
<h3><%= t("proposals.show.share") %></h3> <h3><%= t("proposals.show.share") %></h3>
<div class="social-share-full"> <div class="social-share-full">

View File

@@ -8,6 +8,9 @@
<li> <li>
<%= link_to t("layouts.header.proposals"), proposals_path, class: ("active" if controller_name == "proposals"), accesskey: "p" %> <%= link_to t("layouts.header.proposals"), proposals_path, class: ("active" if controller_name == "proposals"), accesskey: "p" %>
</li> </li>
<li>
<%= link_to t("layouts.header.proposal_ballot"), proposal_ballots_path, class: ("active" if controller_name == "proposal_ballots"), accesskey: "v" %>
</li>
<% if feature?(:spending_proposals) %> <% if feature?(:spending_proposals) %>
<li> <li>
<%= link_to t("layouts.header.spending_proposals"), spending_proposals_path, class: ("active" if controller_name == "spending_proposals"), accesskey: "s" %> <%= link_to t("layouts.header.spending_proposals"), spending_proposals_path, class: ("active" if controller_name == "spending_proposals"), accesskey: "s" %>

View File

@@ -209,6 +209,7 @@ en:
open_data: Open data open_data: Open data
open_gov: Open government open_gov: Open government
proposals: Proposals proposals: Proposals
proposal_ballot: Voting
see_all: See proposals see_all: See proposals
spending_proposals: Spending proposals spending_proposals: Spending proposals
legislation: legislation:
@@ -371,6 +372,15 @@ en:
update: update:
form: form:
submit_button: Save changes submit_button: Save changes
proposal_ballots:
title: "Votings"
description_html: "These are the proposals that have reached the required supports <em>(%{supports})</em> and will be voted."
date_title: "Dates of participation"
date: "September 15 to September 30, 2016"
successfull: "This proposal has reached the required supports and will be voted in the %{voting}."
voting: "next voting"
featured_title: "Next voting"
nothing_to_vote: "There is nothing to vote at the moment."
proposal_notifications: proposal_notifications:
new: new:
title: "Send message" title: "Send message"

View File

@@ -209,6 +209,7 @@ es:
open_data: Datos abiertos open_data: Datos abiertos
open_gov: Gobierno %{open} open_gov: Gobierno %{open}
proposals: Propuestas proposals: Propuestas
proposal_ballot: Votaciones
see_all: Ver propuestas see_all: Ver propuestas
spending_proposals: Presupuestos ciudadanos spending_proposals: Presupuestos ciudadanos
legislation: legislation:
@@ -371,6 +372,15 @@ es:
update: update:
form: form:
submit_button: Guardar cambios submit_button: Guardar cambios
proposal_ballots:
title: "Votaciones"
description_html: "Estas son las propuestas que han alcanzado el número de apoyos necesarios <em>(%{supports})</em> y que pasarán a la siguiente votación."
date_title: "Fechas de participación"
date: "Del 15 de septiembre al 30 de septiembre de 2016"
successfull: "Esta propuesta ha alcanzado los apoyos necesarios y pasará a la %{voting}."
voting: "próxima votación"
featured_title: "Próxima votación"
nothing_to_vote: "No hay nada que votar en este momento."
proposal_notifications: proposal_notifications:
new: new:
title: "Enviar mensaje" title: "Enviar mensaje"