Lots of stuff, I got too tired to keep perfect revision history
[cs356-p2-videostore.git] / app / controllers / bonus_policy_controller.rb
1 class BonusPolicyController < ApplicationController
2   layout "admin"
3
4   before_filter :authorize, :except => ['new', 'create', 'edit', 'update', 'destroy']
5   before_filter :manager, :only => ['new', 'create', 'edit', 'update', 'destroy']
6
7   def index
8     list
9     render :action => 'list'
10   end
11
12   # GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html)
13   verify :method => :post, :only => [ :destroy, :create, :update ],
14          :redirect_to => { :action => :list }
15
16   def list
17     @bonus_policy_pages, @bonus_policies = paginate :bonus_policies, :per_page => 10
18   end
19
20   def show
21     @bonus_policy = BonusPolicy.find(params[:id])
22   end
23
24   def new
25     @bonus_policy = BonusPolicy.new
26   end
27
28   def create
29     @bonus_policy = BonusPolicy.new(params[:bonus_policy])
30     if @bonus_policy.save
31       flash[:notice] = 'BonusPolicy was successfully created.'
32       redirect_to :action => 'list'
33     else
34       render :action => 'new'
35     end
36   end
37
38   def edit
39     @bonus_policy = BonusPolicy.find(params[:id])
40   end
41
42   def update
43     @bonus_policy = BonusPolicy.find(params[:id])
44     if @bonus_policy.update_attributes(params[:bonus_policy])
45       flash[:notice] = 'BonusPolicy was successfully updated.'
46       redirect_to :action => 'show', :id => @bonus_policy
47     else
48       render :action => 'edit'
49     end
50   end
51
52   def destroy
53     BonusPolicy.find(params[:id]).destroy
54     redirect_to :action => 'list'
55   end
56 end