]> projects.mako.cc - selectricity/commitdiff
Started Creation of "advanced" quickvote tab. Also started to create a quickvote...
author<jlsharps@mit.edu> <>
Wed, 22 Aug 2007 22:27:50 +0000 (18:27 -0400)
committer<jlsharps@mit.edu> <>
Wed, 22 Aug 2007 22:27:50 +0000 (18:27 -0400)
app/controllers/quickvote_controller.rb
app/models/election.rb
app/models/quick_vote.rb
app/views/quickvote/_advanced.rhtml [new file with mode: 0644]
app/views/quickvote/create.rhtml
test/unit/quickvote_test.rb [new file with mode: 0644]

index 54784ef46e735749238ea4fc8617bd261cb72d80..0d165cbd458c1f94f9d4569936c92e9bb80d9f80 100644 (file)
@@ -29,6 +29,7 @@ class QuickvoteController < ApplicationController
       # here has not been hitting this page and we can clear any
       # candlist in the flash
       flash.delete(:candlist) if flash.has_key?(:candlist)
+      @quickvote = QuickVote.new
     end
   end
 
@@ -166,3 +167,5 @@ class QuickvoteController < ApplicationController
     @election.candidates.each {|c| @candidates[c.id] = c}
   end
 end
+
+
index 59a10bfbe601387eac1b72de2c9fcec03c99560c..7343d7204070b374eb8b383751b17e0f8ae29b7c 100644 (file)
@@ -15,6 +15,12 @@ class Election < ActiveRecord::Base
   
   require 'date'
   
+  def initialize(params={})
+    super
+    self.enddate = read_attribute( :enddate ) || \
+                   Time.now + 14.days - 1.second
+  end
+
   def other_methods
     if election_method
       @other_methods = ELECTION_TYPES.reject {|i| i == election_method}
@@ -27,11 +33,6 @@ class Election < ActiveRecord::Base
   def startdate
     read_attribute( :startdate ) || Time.now
   end
-  
-  def enddate
-    date = read_attribute( :enddate ) || Time.now + 14
-    date - 1.second
-  end
 
   def enddate=(date)
     date += 1.day
index c0367d6b002ebc8f3058bc480c64edb61bbf3aa5..c04b0d7a3fe3a3539012ba45c50f4cc5632f2687 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.")
@@ -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
diff --git a/app/views/quickvote/_advanced.rhtml b/app/views/quickvote/_advanced.rhtml
new file mode 100644 (file)
index 0000000..5699fd0
--- /dev/null
@@ -0,0 +1,11 @@
+
+<% fields_for 'quickvote', quickvote do |quickform| %>
+
+<span><label for="quickvote_election_method">Election Method</span><br />
+<%= quickform.select ('election_method', 
+    %w(ssd condorcet plurality approval borda) ) %><br />
+
+<span><label for="quickvote_enddate">End Time</span><br />
+<%= quickform.date_select(:enddate) %><br />
+
+<% end %>
index cf91e198a4e15183020a680bea65c51ed49f9241..a7ccd63396e1b8c9ecdeb897188571bb16db47b6 100644 (file)
 
 <%= text_area 'quickvote', 'description', :cols => 50, :rows => 4 %></p>
 
+<%= check_box('options', 'advanced', 
+    :onclick => 'Element.toggle($("advanced")); false;' )%>Advanced
+
+<div id="advanced" style="display: none">
+<%= render :partial => 'advanced', :locals => {:quickvote => @quickvote} %>
+</div>
+<br />
+
 <%= submit_tag "Create Quickvote" -%>
 
 <% end %>
 
+
+
+
+
diff --git a/test/unit/quickvote_test.rb b/test/unit/quickvote_test.rb
new file mode 100644 (file)
index 0000000..4282a70
--- /dev/null
@@ -0,0 +1,11 @@
+require File.dirname(__FILE__) + '/../test_helper'
+
+class QuickVoteTest < Test::Unit::TestCase
+  
+  def correct_enddate
+    
+  end
+  
+  
+  
+end
\ No newline at end of file

Benjamin Mako Hill || Want to submit a patch?