X-Git-Url: https://projects.mako.cc/source/selectricity-live/blobdiff_plain/47fdfaba5a11570f2d7d720ee1c80d616d502c74..a8006b0bf9687f8882c3073eca2e8b4ebc7cde4a:/app/models/quick_vote.rb diff --git a/app/models/quick_vote.rb b/app/models/quick_vote.rb index c0367d6..c04b0d7 100644 --- a/app/models/quick_vote.rb +++ b/app/models/quick_vote.rb @@ -5,6 +5,19 @@ class QuickVote < Election attr_accessor :raw_candidates attr_accessor :reviewed + def initialize(params={}) + super + self.startdate = Time.now + self.active = 1 + self.anonymous = 1 unless self.anonymous + self.enddate = read_attribute( :enddate ) || \ + Time.now + 30.days - 1.second + end + + def enddate + super(30) + end + def validate if not @raw_candidates or @raw_candidates.length < 2 errors.add(nil, "You must list at least two candidates.") @@ -35,14 +48,6 @@ class QuickVote < Election errors.add(:name, " is a reserved word.") end end - - def initialize(params={}) - super - self.startdate = Time.now - self.enddate = Time.now + 30.days - self.active = 1 - self.anonymous = 1 - end def candidatelist=(candlist) @raw_candidates = candlist