X-Git-Url: https://projects.mako.cc/source/selectricity/blobdiff_plain/fc0a6a8d7ea15bcdb27ebdd58721401c7045c6e0..7ee8e40628f6d7b775f48d859dd005de5a5e9afa:/app/models/election.rb diff --git a/app/models/election.rb b/app/models/election.rb old mode 100755 new mode 100644 index 0907e68..cf7bba5 --- a/app/models/election.rb +++ b/app/models/election.rb @@ -10,7 +10,7 @@ class Election < ActiveRecord::Base def startdate read_attribute( :startdate ) || Time.now end - + def enddate date = read_attribute( :enddate ) || Time.now + 14 date - 1.second @@ -22,6 +22,14 @@ class Election < ActiveRecord::Base super(date) end + def votes + votes = Array.new + self.voters.each do |voter| + votes << voter.vote + end + return votes + end + def destroy self.candidates.each do |candidate| candidate.destroy @@ -49,7 +57,7 @@ class Election < ActiveRecord::Base end def quickvote? - quickvote.to_i == 1 + type == 'QuickVote' end def active?