]> projects.mako.cc - selectricity-live/blob - app/controllers/site_controller.rb
Reorganized the README file and added a short list of dependencies.
[selectricity-live] / app / controllers / site_controller.rb
1 class SiteController < ApplicationController
2   layout 'hc'
3   model :user, :election, :account
4
5   def index
6     @quickvotes = QuickVote.find_all(["quickvote = 1"]).sort {|a,b| b.enddate <=> a.enddate}[0..1]
7     # if the person claims they are logged in
8     if session[:user]
9
10       # check to see that we actually have record of them
11       if User.find_all(["id = ?", session[:user].id]).length == 1
12         # if we have record of them, grab the list of their elections
13         session[:user] = User.find(session[:user])
14         @current_elections = session[:user].elections.sort do |a,b|
15           b.enddate <=> a.enddate
16         end
17       else
18         # if we have no record of them, set the session id back to
19         # nothing and start again
20         session[:user] = nil
21       end
22     end
23   end
24
25 end

Benjamin Mako Hill || Want to submit a patch?