Skip to content

Commit

Permalink
Merge branch 'master' of github.com:PartidoDeInternet/AgoraOnRails
Browse files Browse the repository at this point in the history
  • Loading branch information
voodoorai2000 committed Oct 22, 2011
2 parents 27ba41a + 2d42276 commit 9604171
Show file tree
Hide file tree
Showing 38 changed files with 360 additions and 287 deletions.
13 changes: 4 additions & 9 deletions app/helpers/application_helper.rb
@@ -1,4 +1,3 @@
# coding: utf-8
module ApplicationHelper module ApplicationHelper
def hot_categories def hot_categories
@hot_categories ||= Category.hot @hot_categories ||= Category.hot
Expand All @@ -21,18 +20,14 @@ def awesome_truncate(text, length = 30, truncate_string = "...")
end end


def humanize(choice) def humanize(choice)
case choice t(choice)
when "in_favor" then "Sí"
when "against" then "No"
when "abstention" then "Abs"
end
end end


def vote_text(proposal) def who_did_vote(proposal)
if proposal.votes.blank? if proposal.votes.blank?
"<strong>Vota!</strong> Sé el primero en votar".html_safe t(:be_first)
else else
"<strong>Vota!</strong> #{pluralize(proposal.votes.count, 'persona ya lo ha hecho', 'personas ya lo han hecho')}".html_safe pluralize(proposal.votes.count, t(:one_did_it), t(:many_did_it))
end end
end end
end end
26 changes: 18 additions & 8 deletions app/helpers/proposals_helper.rb
@@ -1,24 +1,34 @@
module ProposalsHelper module ProposalsHelper
def proposals_heading def proposals_heading
case parent_type case parent_type
when :category then "Propuestas relacionadas con #{parent.name}" when :category then t(:related_with_category, :category => parent.name)
when :proposer then "Propuestas presentadas por #{parent.name}" when :proposer then t(:proposed_by, :proposer => parent.name)
else else
"Propuestas" t :proposals
end end
end end

def choice_result(proposal, choice)
content_tag :strong, :style => "width:#{percentage_for(proposal, choice)}-width" do
humanize(choice)
end
end

def percentage_for(proposal, choice)
number_to_percentage(proposal.percentage_for(choice.to_sym), :precision => 0)
end


def show_toggle_button(is_admin) def show_toggle_button(is_admin)
if (is_admin and !@proposal.closed?) if is_admin && @proposal.open?
button_to("Finalizar votaci&oacute;n", toggle_proposal_path(@proposal)).html_safe button_to t(:end_voting), toggle_proposal_path(@proposal)
end end
end end


def show_closed_text def show_closed_text
if @proposal.closer_id.present? if @proposal.closed? && @proposal.official_resolution.blank?
"El periodo de votaci&oacute;n para esta propuesta finaliz&oacute; el #{l(@proposal.closed_at)}" t(:closed, :date => l(@proposal.closed_at))
else else
"La Propuesta fue <span class=\"official_resolution\"> #{@proposal.official_resolution}</span> en el Congreso." t(:congress_resolution_html, :resolution => @proposal.official_resolution)
end end


end end
Expand Down
2 changes: 0 additions & 2 deletions app/helpers/proposers_helper.rb

This file was deleted.

3 changes: 1 addition & 2 deletions app/helpers/share_helper.rb
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
module ShareHelper module ShareHelper
def image_url(source) def image_url(source)
abs_path = image_path(source) abs_path = image_path(source)
Expand All @@ -9,7 +8,7 @@ def image_url(source)
end end


def share_text(proposal) def share_text(proposal)
"He votado a través del partido del internet la propuesta #{proposal_url(proposal)}" t(:share_text, :url => proposal_url(proposal))
end end


def share_on_facebook_link(proposal) def share_on_facebook_link(proposal)
Expand Down
2 changes: 0 additions & 2 deletions app/helpers/user_sessions_helper.rb

This file was deleted.

7 changes: 3 additions & 4 deletions app/helpers/votes_helper.rb
@@ -1,11 +1,10 @@
# -*- coding: utf-8 -*-
module VotesHelper module VotesHelper


def confirmation_text(value) def confirmation_text(value)
case value case value
when "no" then "a votar en contra de" when "no" then t(:going_to_vote_against)
when "si" then "a votar a favor de" when "si" then t(:going_to_vote_in_favor)
when "abstencion" then "a abstenerte de votar sobre" when "abstencion" then t(:going_to_abstain)
end end
end end


Expand Down
12 changes: 8 additions & 4 deletions app/models/proposal.rb
Expand Up @@ -79,15 +79,19 @@ def proposer_name
def category_name def category_name
category.name category.name
end end

def closed?
closed_at.present?
end

def open?
closed_at.blank?
end


def close(cid) def close(cid)
self.closed_at = DateTime.now self.closed_at = DateTime.now
self.closer_id = cid self.closer_id = cid
self.save! self.save!
count_votes! count_votes!
end end

def reopen

end
end end
42 changes: 21 additions & 21 deletions app/views/layouts/application.html.erb
Expand Up @@ -6,11 +6,10 @@
<meta http-equiv="content-type" content="text/html; charset=UTF-8" /> <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" href="/stylesheets/populo.css" type="text/css" media="screen" charset="utf-8"/> <link rel="stylesheet" href="/stylesheets/populo.css" type="text/css" media="screen" charset="utf-8"/>
<!--[if lte IE 6]> <!--[if lte IE 6]>
<link rel="stylesheet" href="/stylesheets/populo-ie.css" type="text/css" media="screen" charset="utf-8"/> <link rel="stylesheet" href="/stylesheets/populo-ie.css" type="text/css" media="screen" charset="utf-8"/>
<![endif]--> <![endif]-->
<%= javascript_include_tag 'jquery', 'jquery_tools', 'rails', 'application' %> <%= javascript_include_tag 'jquery', 'jquery_tools', 'rails', 'application' %>
<%= csrf_meta_tag %> <%= csrf_meta_tag %>
<%= render :partial => "shared/google_analytics" %>
<%= yield :head %> <%= yield :head %>
</head> </head>
<body> <body>
Expand All @@ -20,28 +19,29 @@
<div id="wrap"> <div id="wrap">
<div id="wrap-inner"> <div id="wrap-inner">
<div class="wrap-fit"> <div class="wrap-fit">

<section id="header"> <section id="header">
<header>
</header>
<% if current_user %> <% if current_user %>
<nav id="user-nav"> <nav id="user-nav">
<ul> <ul>
<li>Estoy logueado como <%= current_user.name %> y <%= link_to "quiero salir", user_session_path, :method => "delete" %></li> <li>
</ul> <%= t :currently_logged_as, :username => current_user.name,
</nav> :href => link_to(t("want_to_sign_out"), user_session_path, :method => "delete") %>
</li>
</ul>
</nav>
<% end %> <% end %>
</section> </section>


<% flash.each do |key, value| %> <% flash.each do |key, value| %>
<div class="<%= key %>"><%= value %></div> <div class="<%= key %>"><%= value %></div>
<% end %> <% end %>
<%= yield %> <%= yield %>

<aside> <aside>
<dl class="tag_list" id="categories"> <dl class="tag_list" id="categories">
<dt><strong>¿De qué se habla?</strong></dt> <dt><strong><%= t :what_proposals %></strong></dt>
<dd> <dd>
<ul> <ul>
<% hot_categories.each_with_index do |category, index| %> <% hot_categories.each_with_index do |category, index| %>
Expand All @@ -57,7 +57,7 @@
</dl> </dl>


<dl class="tag_list" id="proposers"> <dl class="tag_list" id="proposers">
<dt><strong>¿Quién propone?</strong></dt> <dt><strong><%= t :who_proposed %></strong></dt>
<dd> <dd>
<ul> <ul>
<% hot_proposers.each_with_index do |proposer, index| %> <% hot_proposers.each_with_index do |proposer, index| %>
Expand All @@ -73,23 +73,23 @@
</dl> </dl>


</aside> </aside>

</div> </div>
</div> </div>
</div> </div>


<footer> <footer>
<div class="wrap-fit"> <div class="wrap-fit">
<section id="total-votes"><strong><%= number_with_delimiter Vote.count %></strong> votos a través de AgoraOnRails</section> <section id="total-votes"><strong><%= number_with_delimiter Vote.count %></strong> <%= t :votes_through_agora %></section>
<p>Proyecto desarrollado a partir de <a href="http://populo.heroku.com/">Populo</a></p> </div>
</div> </footer>
</footer>


<div id="overlay"> <div id="overlay">
<div id="overlay-inner"> <div id="overlay-inner">
<iframe name="overlay"></iframe> <iframe name="overlay"></iframe>
</div> </div>
</div> </div>


<%= render :partial => "shared/google_analytics" if Rails.env == 'production' %>
</body> </body>
</html> </html>
3 changes: 1 addition & 2 deletions app/views/layouts/mini_application.html.erb
Expand Up @@ -10,7 +10,6 @@
<![endif]--> <![endif]-->
<%= javascript_include_tag 'jquery', 'jquery_tools', 'rails', 'application' %> <%= javascript_include_tag 'jquery', 'jquery_tools', 'rails', 'application' %>
<%= csrf_meta_tag %> <%= csrf_meta_tag %>
<%= render :partial => "shared/google_analytics" %>
</head> </head>
<body id="mini"> <body id="mini">


Expand All @@ -32,6 +31,6 @@


</div> </div>
</div> </div>

<%= render :partial => "shared/google_analytics" if Rails.env == 'production' %>
</body> </body>
</html> </html>
17 changes: 17 additions & 0 deletions app/views/proposals/_form.html.erb
@@ -0,0 +1,17 @@
<%= form_tag new_proposal_vote_path(@proposal), {:method => :get, :class => "vote"} do %>
<fieldset>
<strong><%= t :vote_proposal %></strong>
<div>
<%= label_tag :explanation, t(:explain) %><br/>
<%= text_area_tag :explanation, nil, :size => "40x5" %>
</div>
<div>
<%= label_tag :link, t(:optional_link) %><br/>
<%= text_field_tag :link, nil, :size => "40" %>
</div>
<br/>
<button type="submit" name="value" value="si" class="si"><span><%= t(:yes_option)%></span></button>
<button type="submit" name="value" value="no" class="no"><span><%= t(:no_option)%></span></button>
<button type="submit" name="value" value="abstencion" class="abstencion"><span><%= t(:abstention)%></span></button>
</fieldset>
<% end %>
6 changes: 3 additions & 3 deletions app/views/proposals/_vote_calculator.html.erb
@@ -1,8 +1,8 @@
<%= form_tag proposal_path(@proposal), :method => :get do %> <%= form_tag proposal_path(@proposal), :method => :get do %>
<p>Calcula el voto de los representantes:</p> <p><%= t :calculate_representatives_vote %></p>
<p> <p>
<%= label_tag 'numero de representantes'%> <%= label_tag t(:representatives_number)%>
<%= text_field_tag 'representative_count' %> <%= text_field_tag 'representative_count' %>
</p> </p>
<%= submit_tag 'Calcular'%> <%= submit_tag t(:calculate) %>
<% end %> <% end %>
24 changes: 0 additions & 24 deletions app/views/proposals/edit.html.erb

This file was deleted.

4 changes: 2 additions & 2 deletions app/views/proposals/index.html.erb
@@ -1,8 +1,8 @@
<% @title = proposals_heading %> <% @title = proposals_heading %>
<section id="content"> <section id="content">
<ul id="breadcrumb"> <ul id="breadcrumb">
<li><a href="/">Inicio »</a></li> <li><a href="/"><%= t(:start) %> »</a></li>
<li><%= link_to "Proposiciones", proposals_path %></li> <li><%= link_to t(:proposals), proposals_path %></li>
</ul> </ul>


<header class="proposal-head"> <header class="proposal-head">
Expand Down

0 comments on commit 9604171

Please sign in to comment.