diff --git a/app/controllers/proposals_controller.rb b/app/controllers/proposals_controller.rb index 578395ab3..898ad9949 100644 --- a/app/controllers/proposals_controller.rb +++ b/app/controllers/proposals_controller.rb @@ -28,6 +28,7 @@ class ProposalsController < ApplicationController def index_customization load_retired load_featured + load_proposal_ballots end def vote @@ -97,4 +98,8 @@ class ProposalsController < ApplicationController end end + def load_proposal_ballots + @proposal_ballots = Proposal.successfull.sort_by_confidence_score + end + end diff --git a/app/models/proposal.rb b/app/models/proposal.rb index 9a92a8d18..4c3cc9e40 100644 --- a/app/models/proposal.rb +++ b/app/models/proposal.rb @@ -47,6 +47,7 @@ class Proposal < ActiveRecord::Base scope :last_week, -> { where("proposals.created_at >= ?", 7.days.ago)} scope :retired, -> { where.not(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 "#{id}-#{title}".parameterize @@ -155,6 +156,10 @@ class Proposal < ActiveRecord::Base Setting['votes_for_proposal_success'].to_i end + def successfull? + total_votes >= Proposal.votes_needed_for_success + end + def notifications proposal_notifications end diff --git a/app/views/proposals/_proposal.html.erb b/app/views/proposals/_proposal.html.erb index 70c2b9c89..464710493 100644 --- a/app/views/proposals/_proposal.html.erb +++ b/app/views/proposals/_proposal.html.erb @@ -1,10 +1,12 @@ -
+
Proposal.votes_needed_for_success) %>" + data-type="proposal">
+
- <% cache [locale_and_user_status(proposal), 'index', proposal, proposal.author] do %> <%= t("proposals.proposal.proposal") %> @@ -50,11 +52,21 @@
-
- <%= render 'votes', - { proposal: proposal, vote_url: vote_proposal_path(proposal, value: 'yes') } %> +
+ <% if proposal.successfull? %> +
+

+ <%= t("proposal_ballots.successfull", + voting: link_to(t("proposal_ballots.voting"), proposal_ballots_path)).html_safe %> +

+
+ <% else %> +
+ <%= render 'votes', + { proposal: proposal, vote_url: vote_proposal_path(proposal, value: 'yes') } %> +
+ <% end %>
-
diff --git a/app/views/proposals/index.html.erb b/app/views/proposals/index.html.erb index 6f6516890..ff9c23d08 100644 --- a/app/views/proposals/index.html.erb +++ b/app/views/proposals/index.html.erb @@ -30,8 +30,20 @@ <% if has_banners %> <%= render "shared/banner" %> <% end %> - - <% if @featured_proposals.present? %> + + <% if @proposal_ballots.present? %> + + <% elsif @featured_proposals.present? %>