]> projects.mako.cc - selectricity/blob - app/controllers/front_controller.rb
8b8ae68203a7a2de1a6e396be6c72c0b674e81eb
[selectricity] / app / controllers / front_controller.rb
1 class FrontController < ApplicationController
2   layout 'frontpage'
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.startdate <=> a.startdate}[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       end
25     end
26   end
27
28 end

Benjamin Mako Hill || Want to submit a patch?