Allow custimizable graph sizes, to fit with newly modular results page. Also,
[selectricity] / app / models / quick_vote.rb
index c0367d6b002ebc8f3058bc480c64edb61bbf3aa5..494f7ac364bfb6b7dd53226bce0f138f05c10c60 100644 (file)
@@ -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.")
@@ -34,14 +47,11 @@ class QuickVote < Election
     if name =~ /^(create|index|confirm|change|results)$/
       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
+    
+    if enddate < startdate
+      errors.add(nil, "QuickVotes can't end before they start!")
+    end
+    
   end
 
   def candidatelist=(candlist)

Benjamin Mako Hill || Want to submit a patch?