Major commit adding about information and more before site goes live.
[selectricity-live] / app / controllers / application.rb
1 # Filters added to this controller will be run for all controllers in
2 # the application.  Likewise, all the methods added will be available
3 # for all controllers.
4
5 class ApplicationController < ActionController::Base
6   # add authentication methods and hooks
7   include AuthenticatedSystem
8   helper :user
9   require_dependency "user"
10
11   # add sitealizer statistics and tracking information
12   include Sitealizer
13   
14   before_filter :use_sitealizer, :add_stylesheets
15    
16   def initialize
17     @stylesheets = []
18     
19     # this is defined is a sketchy way in the sitealizer mixin
20     # initalize. since i'm overloading that, i'm calling it here
21     $visits = [] unless $visits
22   end
23             
24   def add_stylesheets
25     file = "#{Dir.pwd}/public/stylesheets/#{controller_name}.css"
26     if File.exists? file
27       @stylesheets << controller_name
28     end
29   end
30
31   #both election_controller and quickvote_controller need this method
32   def sort_candidates
33     @vote = Vote.find(params[:id])
34
35     @vote.rankings.each do |ranking|
36       ranking.rank = params['rankings-list'].index(ranking.candidate.id.to_s) + 1
37       ranking.save
38     end
39     render :nothing => true
40   end
41 end

Benjamin Mako Hill || Want to submit a patch?