Updated quickvote creation to fix expanding and unexpanding.
author<mako@atdot.cc> <>
Wed, 29 Aug 2007 20:54:17 +0000 (16:54 -0400)
committer<mako@atdot.cc> <>
Wed, 29 Aug 2007 20:54:17 +0000 (16:54 -0400)
app/controllers/quickvote_controller.rb
app/models/election.rb
app/models/quick_vote.rb

index 6886ca40e32f844469f50666d1c63ca130ed8874..ea7711fa2fc5981b74da5f7e66e450838ee4df78 100644 (file)
@@ -25,10 +25,6 @@ class QuickvoteController < ApplicationController
 
     show_advanced ||= false
 
 
     show_advanced ||= false
 
-    # render the sidebar
-    @sidebar_content = render_to_string(:partial => 'create_sidebar',
-      :locals => {:show_advanced => show_advanced})
-
     if params[:quickvote]
 
       # store the candidate grabbed through ajax and stored in flash
     if params[:quickvote]
 
       # store the candidate grabbed through ajax and stored in flash
@@ -49,6 +45,9 @@ class QuickvoteController < ApplicationController
         @sidebar_content = ''
         render :action => 'success'
       else
         @sidebar_content = ''
         render :action => 'success'
       else
+        # render the sidebar
+        @sidebar_content = render_to_string(:partial => 'create_sidebar',
+          :locals => {:show_advanced => show_advanced})
         flash.keep(:candidate_names)
       end 
 
         flash.keep(:candidate_names)
       end 
 
@@ -58,6 +57,8 @@ class QuickvoteController < ApplicationController
       # candidate_names list in the flash
       flash.delete(:candidate_names) if flash.has_key?(:candidate_names)
       @quickvote = QuickVote.new
       # candidate_names list in the flash
       flash.delete(:candidate_names) if flash.has_key?(:candidate_names)
       @quickvote = QuickVote.new
+      @sidebar_content = render_to_string(:partial => 'create_sidebar',
+        :locals => {:show_advanced => show_advanced})
     end
 
   end
     end
 
   end
index a77f4457bb581fba8588e1cf7ee479932851f409..9c6337fdcf56ff78d7ee1d63a04ba1bfedf23bf0 100644 (file)
@@ -18,7 +18,7 @@ class Election < ActiveRecord::Base
   def initialize(params={})
     super
     self.enddate = read_attribute( :enddate ) || \
   def initialize(params={})
     super
     self.enddate = read_attribute( :enddate ) || \
-                   Time.now + 14.days - 1.second
+                   Time.now + 30.days - 1.second
   end
 
   def other_methods
   end
 
   def other_methods
@@ -34,12 +34,6 @@ class Election < ActiveRecord::Base
     read_attribute( :startdate ) || Time.now
   end
 
     read_attribute( :startdate ) || Time.now
   end
 
-  def enddate=(date)
-    date += 1.day
-    date = Time.gm(*date)
-    super(date)
-  end
-
   def votes
     votes = Array.new
     self.voters.each do |voter|
   def votes
     votes = Array.new
     self.voters.each do |voter|
index e0bab76fccf4a8654dffabb461eb105aadd6a1fd..de78813153025698796b8ce274f711072cf984e5 100644 (file)
@@ -11,8 +11,6 @@ class QuickVote < Election
     self.startdate = Time.now
     self.active = 1
     self.anonymous = 1 unless self.anonymous
     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 validate
   end
   
   def validate

Benjamin Mako Hill || Want to submit a patch?