]> projects.mako.cc - selectricity/blobdiff - app/controllers/elections_controller.rb
Variety of improvements and additions:
[selectricity] / app / controllers / elections_controller.rb
index 696028e1287baabe6f3431ea12c337bcee0e4238..b3406a84ab64941ce8a4c05e415937aec09f4e92 100644 (file)
@@ -1,3 +1,5 @@
+require 'uniq_token'
+
 class ElectionsController < ApplicationController
   model :raw_voter_list, :voter, :vote, :candidate
 
@@ -104,10 +106,17 @@ class ElectionsController < ApplicationController
 
     def process_incoming_voters(raw_voter_list)
       incoming_voters = RawVoterList.new( raw_voter_list )
+      token_generator = UniqueTokenGenerator.new( 16 )
 
       unless incoming_voters.entries.empty?
         incoming_voters.each do |new_voter|
 
+         until new_voter.password and \
+               Voter.find_all( [ "password = ?", new_voter.password ]).empty?
+           new_voter.password = token_generator.token
+         end
+        
+         breakpoint
           if incoming_voters.email == 0
             new_voter.contacted = 1
          elsif incoming_voters.email == 1
@@ -127,4 +136,8 @@ class ElectionsController < ApplicationController
       @raw_voter_list = RawVoterList.new
       @raw_voter_list.email = incoming_voters.email
     end
+
+    def email_voter
+    end
+
 end

Benjamin Mako Hill || Want to submit a patch?