]> projects.mako.cc - selectricity-live/blob - app/controllers/application.rb
Add links to create new election/quick vote on the account summary screen.
[selectricity-live] / app / controllers / application.rb
1 # Selectricity: Voting Machinery for the Masses
2 # Copyright (C) 2007, 2008 Benjamin Mako Hill <mako@atdot.cc>
3 # Copyright (C) 2007 Massachusetts Institute of Technology
4 #
5 # This program is free software. Please see the COPYING file for
6 # details.
7
8 # Filters added to this controller will be run for all controllers in
9 # the application.  Likewise, all the methods added will be available
10 # for all controllers.
11
12 class ApplicationController < ActionController::Base
13   include AuthenticatedSystem
14   helper :user
15   require_dependency "user"
16
17   include Sitealizer
18   before_filter :add_stylesheets
19   #before_filter :use_sitealizer
20    
21   def initialize
22     @stylesheets = []
23
24         
25     # this is defined is a sketchy way in the sitealizer mixin
26     # initalize. since i'm overloading that, i'm calling it here
27     $visits = [] unless $visits
28   end
29             
30   def add_stylesheets
31     file = "#{Dir.pwd}/public/stylesheets/#{controller_name}.css"
32     if File.exists? file
33       @stylesheets << controller_name
34     end
35   end
36
37   #both election_controller and quickvote_controller need this method
38   def sort_candidates
39     @vote = Vote.find(params[:id])
40     
41     @vote.rankings.each do |ranking|
42       ranking.rank = params['rankings-list'].index(ranking.candidate.id.to_s) + 1
43       ranking.save
44     end
45     render :nothing => true
46   end
47 end

Benjamin Mako Hill || Want to submit a patch?