]> projects.mako.cc - selectricity-live/blobdiff - app/models/election.rb
Suppress description of voter-verifiability unless election is verifiable.
[selectricity-live] / app / models / election.rb
index b48c9238c0bf39a2a79f1a044d0ec723626a4395..ac8d628b16f003a1848f78215aa6f9b4e9811412 100644 (file)
@@ -184,13 +184,23 @@ class Election < ActiveRecord::Base
     end
   end
 
+  def just_before_midnight(datetime)
+    if datetime.instance_of? DateTime
+      off = datetime.offset
+    else
+      off = Rational(datetime.utc_offset, 60*60*24)
+    end
+    return DateTime.new(datetime.year, datetime.month, datetime.day,
+                        23, 59, 59, off)
+  end
+
   private
   def enforce_constraints
+    # elections end just before midnight
+    self.enddate = just_before_midnight(self.enddate)
     # kiosks can't be authenticated
     self.authenticated = false if kiosk?
     return true
   end
 
 end
-
-

Benjamin Mako Hill || Want to submit a patch?