]> projects.mako.cc - selectricity/blob - app/controllers/site_controller.rb
Put in a pie graph for Plurality votes. ALso slimmed down victories_and_ties method...
[selectricity] / app / controllers / site_controller.rb
1 class SiteController < ApplicationController
2   layout 'main'
3   require_dependency "user"
4   require_dependency "election"
5   require_dependency "account"
6
7   def index
8     @quickvotes = QuickVote.find(:all).sort {|a,b| b.enddate <=> a.enddate}[0..1]
9     # if the person claims they are logged in
10    
11     if logged_in?
12       # check to see that we actually have record of them
13       if User.exists?(session[:user])
14         username = User.find(session[:user]).login
15         # if we have record of them, grab the list of their elections
16         session[:user] = User.find(session[:user])
17         @current_elections = session[:user].elections.sort do |a,b|
18           b.enddate <=> a.enddate
19         end
20       else
21         # if we have no record of them, set the user back to
22               # nothing and start again
23         session[:user] = nil
24         
25       end
26     end
27   end
28
29 end

Benjamin Mako Hill || Want to submit a patch?