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 @@ -