diff options
author | Joachim Filip Ignacy Bartosik <jbartosik@gmail.com> | 2011-06-30 16:43:15 +0200 |
---|---|---|
committer | Joachim Filip Ignacy Bartosik <jbartosik@gmail.com> | 2011-07-06 16:49:52 +0200 |
commit | ef70c52fea7c44b08ee7bec9a1657403cf47d283 (patch) | |
tree | 1488cab5a968c9408e32a4e2346f2dbc5032ec65 /site/app/models/voting_option.rb | |
parent | Distinguish votes made during council voting and community voice (diff) | |
download | council-webapp-ef70c52fea7c44b08ee7bec9a1657403cf47d283.tar.gz council-webapp-ef70c52fea7c44b08ee7bec9a1657403cf47d283.tar.bz2 council-webapp-ef70c52fea7c44b08ee7bec9a1657403cf47d283.zip |
Show community votes properly
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? |