summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
4ef17d5)
votename. This identifier may be either just a votename or an integer id.
#############################################################
def index
#############################################################
def index
- @election = QuickVote.find_all(["name = ?", params[:votename]])[0]
+ @election = ident_to_quickvote(params[:ident])
# if the person has specified an election, we show them the voting
# page. otherwise, we redirect back to main the page
# if the person has specified an election, we show them the voting
# page. otherwise, we redirect back to main the page
unless @voter
# create a new voter and populate it
@voter = QuickVoter.new
unless @voter
# create a new voter and populate it
@voter = QuickVoter.new
- @voter.election = QuickVote.find_all( [ "name = ?", params[:votename] ] )[0]
+ @voter.election = @election
@voter.session_id = session.session_id
# create new vote and make it the defaulted sorted list
@voter.session_id = session.session_id
# create new vote and make it the defaulted sorted list
def confirm
# we need the election to verify that we have the right voter
def confirm
# we need the election to verify that we have the right voter
- election = QuickVote.find_all( [ "name = ?", params[:votename] ] )[0]
+ election = ident_to_quickvote(params[:ident])
# find out who the voter is for this election
@voter = QuickVoter.find_all(["session_id = ? and election_id = ?",
# find out who the voter is for this election
@voter = QuickVoter.find_all(["session_id = ? and election_id = ?",
if not @voter
# we have not seen this voter before. something is wrong, try
# again
if not @voter
# we have not seen this voter before. something is wrong, try
# again
- redirect_to quickvote_url( :votename => params[:votename] )
+ redirect_to quickvote_url( :ident => params[:ident] )
elsif @voter.voted?
# this person has already voted, we try again
flash[:notice] = "You have already voted!"
elsif @voter.voted?
# this person has already voted, we try again
flash[:notice] = "You have already voted!"
- redirect_to quickvote_url( :votename => params[:votename] )
+ redirect_to quickvote_url( :ident => params[:ident] )
else
# record the ip address for posterity
else
# record the ip address for posterity
def change
voter = QuickVoter.find_all(["session_id = ?", session.session_id])[0]
voter.destroy
def change
voter = QuickVoter.find_all(["session_id = ?", session.session_id])[0]
voter.destroy
- redirect_to quickvote_url( :votename => params[:votename] )
+ redirect_to quickvote_url( :ident => params[:ident] )
###############################################################
def results
###############################################################
def results
- @election = QuickVote.find_all(["name = ?", params[:votename]] )[0]
+ @election = ident_to_quickvote(params[:ident])
# initalize the tallies to empty arrays
preference_tally = Array.new
# initalize the tallies to empty arrays
preference_tally = Array.new
@election.candidates.each {|c| @candidates[c.id] = c}
end
@election.candidates.each {|c| @candidates[c.id] = c}
end
+ private
+ def ident_to_quickvote(ident)
+ if ident.match(/^\d+$/)
+ quickvote = QuickVote.find(ident)
+ else
+ quickvote = QuickVote.find_all(["name = ?", ident])[0]
+ end
+
+ return quickvote
+ end
+
<p>You have already voted. You can:</p>
<ul>
<p>You have already voted. You can:</p>
<ul>
- <li><%= link_to "Change your vote.", quickaction_url( :votename => @voter.election.name, :action => 'change' ) %></li>
+ <li><%= link_to "Change your vote.", quickaction_url( :ident => @voter.election.name, :action => 'change' ) %></li>
- <li><%= link_to "View election results.", quickaction_url( :votename => @voter.election.name, :action => 'results' ) %></li>
+ <li><%= link_to "View election results.", quickaction_url( :ident => @voter.election.name, :action => 'results' ) %></li>
<div class="clearbox"></div>
<div class="clearbox"></div>
-<%= button_to "Confirm Vote", quickaction_url( :action => 'confirm', :votename => @voter.election.name) %>
+<%= button_to "Confirm Vote", quickaction_url( :action => 'confirm', :ident => @voter.election.name) %>
<%= sortable_element 'rankings-list',
:url => { :action => "sort_candidates" , :id => @voter.vote.id },
<%= sortable_element 'rankings-list',
:url => { :action => "sort_candidates" , :id => @voter.vote.id },
<p>Please direct voters to:</p>
<blockquote><strong>
<p>Please direct voters to:</p>
<blockquote><strong>
- <%= quickvote_url( :votename => @quickvote.name ) -%>
+ <%= quickvote_url( :ident => @quickvote.name ) -%>
</strong></blockquote>
<p>This vote will end on <em><%= @quickvote.enddate.strftime('%A, %B %d, %Y') %></em></p>
</strong></blockquote>
<p>This vote will end on <em><%= @quickvote.enddate.strftime('%A, %B %d, %Y') %></em></p>
HyperChad site. Voters do not need to log in or authenticate to
participate in this election.</p>
HyperChad site. Voters do not need to log in or authenticate to
participate in this election.</p>
-<p><%= link_to "Jump to QuickVote", quickvote_url( :votename => @quickvote.name ) %></p>
+<p><%= link_to "Jump to QuickVote", quickvote_url( :ident => @quickvote.name ) %></p>
<p>Thanks you voting! You can:</p>
<ul>
<p>Thanks you voting! You can:</p>
<ul>
- <li><%= link_to "Change Your Vote", quickaction_url( :votename => @voter.election.name, :action => 'change' ) %></li>
+ <li><%= link_to "Change Your Vote", quickaction_url( :ident => @voter.election.name, :action => 'change' ) %></li>
- <li><%= link_to "View Current Results", quickaction_url( :votename => @voter.election.name, :action => 'results' ) %></li>
+ <li><%= link_to "View Current Results", quickaction_url( :ident => @voter.election.name, :action => 'results' ) %></li>
<ul>
<% for quickvote in @quickvotes %>
<ul>
<% for quickvote in @quickvotes %>
-<li><%= link_to (quickvote.shortdesc || "Unnamed"), quickvote_url(:votename => quickvote.name) %></li>
+<li><%= link_to (quickvote.shortdesc || "Unnamed"), quickvote_url(:ident => quickvote.name) %></li>
<em>(For example, 123 or 321 or 213, etc.)</em></p>
<% if @voter.election.quickvote? %>
<em>(For example, 123 or 321 or 213, etc.)</em></p>
<% if @voter.election.quickvote? %>
- <%= form_tag quickaction_url( :votename => @voter.election.name, :action => 'confirm') %>
+ <%= form_tag quickaction_url( :ident => @voter.election.name, :action => 'confirm') %>
<% else %>
<%= form_tag :action => 'review', :id => @voter.password %>
<% end %>
<% else %>
<%= form_tag :action => 'review', :id => @voter.password %>
<% end %>
:controller => 'quickvote',
:requirements => { :action => /(create|add_candidate|sort_candidates)/ }
:controller => 'quickvote',
:requirements => { :action => /(create|add_candidate|sort_candidates)/ }
- map.quickaction 'quickvote/:votename/:action',
+ map.quickaction 'quickvote/:ident/:action',
:controller => 'quickvote',
:requirements => { :action => /(change|confirm|results)/ }
:controller => 'quickvote',
:requirements => { :action => /(change|confirm|results)/ }
- map.quickvote 'quickvote/:votename',
+ map.quickvote 'quickvote/:ident',
:controller => 'quickvote', :action => 'index'
# Allow downloading Web Service WSDL as a file with an extension
:controller => 'quickvote', :action => 'index'
# Allow downloading Web Service WSDL as a file with an extension