X-Git-Url: https://projects.mako.cc/source/selectricity/blobdiff_plain/dc7d60a0de460c72d292b43616eb97a8b34741c8..3096416bbb8fdc92d7619aecc8237a57532d9066:/app/models/vote.rb?ds=sidebyside diff --git a/app/models/vote.rb b/app/models/vote.rb index 429e212..014899d 100644 --- a/app/models/vote.rb +++ b/app/models/vote.rb @@ -41,6 +41,11 @@ class Vote < ActiveRecord::Base self.rankings << ranking end end + + def destroy + self.destroy_rankings + super + end def destroy_rankings rankings.each { |ranking| ranking.destroy } @@ -49,18 +54,16 @@ class Vote < ActiveRecord::Base def confirm! self.confirmed = 1 self.save - - token.destroy and token.reload if token - self.token = Token.new - self.save + + unless self.voter.election.quickvote? + token.destroy and token.reload if token + self.token = Token.new + self.save + end end def confirm? - if confirm == 1 - return true - else - return false - end + confirmed == 1 end def votestring=(string="") @@ -73,4 +76,8 @@ class Vote < ActiveRecord::Base self.votes = rel_votes.collect { |vote| candidate_ids[ vote - 1 ] } end + def votestring + self.votes.join("") + end + end