]> projects.mako.cc - selectricity/commitdiff
Fixed all triggerable DeprecationWarnings. BE ON LOOKOUT FOR REGRESSIONS.
authorJohn Dong <jdong@mit.edu>
Fri, 17 Aug 2007 21:31:45 +0000 (17:31 -0400)
committerJohn Dong <jdong@mit.edu>
Fri, 17 Aug 2007 21:31:45 +0000 (17:31 -0400)
app/controllers/application.rb
app/controllers/quickvote_controller.rb
app/controllers/voter_controller.rb
app/models/election.rb
app/models/full_voter.rb
app/models/quick_vote.rb
app/models/selectricity_service.rb
app/models/token.rb

index 8c6f8aeabfc803bbd538516f06365afe69e90578..9b4803092dfc48e4c3ed6a006204de60ae39323e 100644 (file)
@@ -4,6 +4,6 @@
 class ApplicationController < ActionController::Base
   include AuthenticatedSystem
   helper :user
-  model :user
+  require_dependency "user"
   
 end
index e327ed6a17a55ed967e8f24120299554bc640794..8b853ebd1a70274a5562a9d04c46ab4101153a25 100644 (file)
@@ -59,7 +59,7 @@ class QuickvoteController < ApplicationController
 
       # look to see that the voter has been created and has voted in
       # this election, and has confirmed their vote
-      @voter = QuickVoter.find_all(["session_id = ? and election_id = ?",
+      @voter = QuickVoter.find(:all, :conditions => ["session_id = ? and election_id = ?",
                                   session.session_id, @election.id])[0]
 
       # if the voter has not voted we destroy them
@@ -92,7 +92,7 @@ class QuickvoteController < ApplicationController
     election = QuickVote.ident_to_quickvote(params[:ident])
 
     # find out who the voter is for this election
-    @voter = QuickVoter.find_all(["session_id = ? and election_id = ?", 
+    @voter = QuickVoter.find(:all, :conditions => ["session_id = ? and election_id = ?", 
                                  session.session_id, election.id])[0]
   
     if not @voter
@@ -122,7 +122,7 @@ class QuickvoteController < ApplicationController
   end
  
   def change
-    voter = QuickVoter.find_all(["session_id = ?", session.session_id])[0]
+    voter = QuickVoter.find(:all, :conditions => ["session_id = ?", session.session_id])[0]
     voter.destroy
     redirect_to quickvote_url( :ident => params[:ident] )
   end
index 779e83f15aa8bc6eb8862fc0420e34685d241112..e94f4a76f0faed8e1994d30356c41fef851b0387 100644 (file)
@@ -7,7 +7,7 @@ class VoterController < ApplicationController
   def index
     password = params[:id]
     password = params[:vote][:password] if params[:vote]
-    if @voter = FullVoter.find_all( [ "password = ?", password ] )[0]
+    if @voter = FullVoter.find(:all, :conditions => [ "password = ?", password ] )[0]
       render :action => 'fullvote'
     end
   end
@@ -41,7 +41,7 @@ class VoterController < ApplicationController
   private
   def authenticate
     password = params[:id]
-    @voter = FullVoter.find_all( [ "password = ?", password ] )[0]
+    @voter = FullVoter.find(:all, :conditions => [ "password = ?", password ] )[0]
   end
 end
 
index cf7bba58a2974f409a2828226d4dd43dc2f023ac..3baeef08e16fe95192f9b5810fe6b43c9de4fcba 100644 (file)
@@ -57,7 +57,7 @@ class Election < ActiveRecord::Base
   end
   
   def quickvote?
-    type == 'QuickVote'
+    self.class == 'QuickVote'
   end
 
   def active?
index 04071a0f398555adaf1bd10b4b0a6cf25ecc243b..980fb5cf3c0fdeef0c043be9aeabe33233f6a874 100644 (file)
@@ -5,7 +5,7 @@ class FullVoter < Voter
   def create_password
     token_generator = UniqueTokenGenerator.new( 16 )
     until password and not password.empty? \
-          and Voter.find_all( [ "password = ?", password ]).empty?
+          and Voter.find(:all, :conditions => [ "password = ?", password ]).empty?
       self.password = token_generator.token
     end
   end
index ad727170f036c2b60019ffe6d7a63759d6ddfd8f..fef4ef86125bd98f3c2f91ed58a0795262004792 100644 (file)
@@ -88,7 +88,7 @@ class QuickVote < Election
     if ident.match(/^\d+$/)
       quickvote = QuickVote.find(ident)
     else
-      quickvote = QuickVote.find_all(["name = ?", ident])[0]
+      quickvote = QuickVote.find(:all, :conditions => ["name = ?", ident])[0]
     end
 
     return quickvote
index 9e276ef502e89b0a41acde7c7f9ef25412cb3342..6d338dee9905d11edd407aebdd2e9ad72f1f2d16 100644 (file)
@@ -7,10 +7,10 @@ class SelectricityService < ActionWebService::Base
     if election
       candidates=election.candidates.collect { |c| c.id }
       vote_list[0].each do |vote|
-        raise ArgumentError.new "Invalid Candidate ID #{vote}" unless candidates.index(vote)
+        raise ArgumentError.new("Invalid Candidate ID #{vote}") unless candidates.index(vote)
       end
-      raise ArgumentError.new "You must rank all candidates" unless candidates.length <= vote_list[0].length
-      raise ArgumentError.new "Please rank each candidate only once" if vote_list[0].uniq!
+      raise ArgumentError.new("You must rank all candidates") unless candidates.length <= vote_list[0].length
+      raise ArgumentError.new("Please rank each candidate only once") if vote_list[0].uniq!
       voter = QuickVoter.new
       voter.election = election
       voter.ipaddress = "XMLRPC Request"
@@ -22,7 +22,7 @@ class SelectricityService < ActionWebService::Base
       voter.vote.confirm!
       voter.save!
     else
-      raise ArgumentError.new "Cannot find election #{election_name}"
+      raise ArgumentError.new("Cannot find election #{election_name}")
     end
   end
   def quickvote_candidate_ids_to_names(shortname, id_list)
@@ -86,14 +86,14 @@ class SelectricityService < ActionWebService::Base
   end
   def list_quickvotes()
     all=Array.new
-    QuickVote.find_all.each do |election|
+    QuickVote.find(:all).each do |election|
       all << get_quickvote(election.name)
     end
     return all
   end
   def get_quickvote(shortname)
     return ElectionStruct.new unless election=QuickVote.ident_to_quickvote(shortname)
-    return ElectionStruct.new (:id => election.id, :name => election.name, :description => election.description, :candidate_ids => election.candidates.collect {|c| c.id }, :candidate_names => election.candidates.collect {|c| c.name } )
+    return ElectionStruct.new(:id => election.id, :name => election.name, :description => election.description, :candidate_ids => election.candidates.collect {|c| c.id }, :candidate_names => election.candidates.collect {|c| c.name } )
   end
   def create_quickvote(election)
     qv=QuickVote.new(:name => election.name, :description => election.description)
index 2bab51314f0df581cd22684811fe0360d8025918..4ed9598f15cddc4888a4c32612269ad3f0f124d2 100644 (file)
@@ -5,7 +5,7 @@ class Token < ActiveRecord::Base
     super
 
     token_generator = UniqueTokenGenerator.new( 16 )
-    until not token.empty? and Token.find_all( [ "token = ?", token ]).empty?
+    until not token.empty? and Token.find(:all, :conditions => [ "token = ?", token ]).empty?
       self.token = token_generator.token
     end
 

Benjamin Mako Hill || Want to submit a patch?