class ApplicationController < ActionController::Base
include AuthenticatedSystem
helper :user
- model :user
+ require_dependency "user"
end
# 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
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
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
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
private
def authenticate
password = params[:id]
- @voter = FullVoter.find_all( [ "password = ?", password ] )[0]
+ @voter = FullVoter.find(:all, :conditions => [ "password = ?", password ] )[0]
end
end
end
def quickvote?
- type == 'QuickVote'
+ self.class == 'QuickVote'
end
def active?
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
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
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"
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)
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)
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