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

Benjamin Mako Hill || Want to submit a patch?