diff options
Diffstat (limited to 'site/app/models/voting_option.rb')
-rw-r--r-- | site/app/models/voting_option.rb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/site/app/models/voting_option.rb b/site/app/models/voting_option.rb index b9c2226..9ece560 100644 --- a/site/app/models/voting_option.rb +++ b/site/app/models/voting_option.rb @@ -17,6 +17,16 @@ class VotingOption < ActiveRecord::Base description end + def community_votes + votes_for_this = votes.council_vote_is(false).count + votes_total = Vote.for_item(agenda_item.id).council_vote_is(false).count + + return "No community votes for this item yet." if votes_total.zero? + + votes_percentage = (100 * votes_for_this.to_f/votes_total).round + "#{votes_for_this} of #{votes_total} (#{votes_percentage}%) votes." + end + # --- Permissions --- # def create_permitted? |