Massive Cleanup
[cs356-p2-videostore.git] / app / controllers / game_policy_controller.rb
1 class GamePolicyController < ApplicationController
2   layout "admin"
3
4   # Make sure that the user has logged in before they can take any action
5   before_filter :authorize, :only => [:index, :list, :show]
6
7   # Make sure the user is a manager if they want to modify data
8   before_filter :manager, :only => [:new, :create, :edit, :update, :destroy]
9
10   def index
11     list
12     render :action => 'list'
13   end
14
15   # GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html)
16   verify :method => :post, :only => [ :destroy, :create, :update ],
17          :redirect_to => { :action => :list }
18
19   def list
20     @game_policy_pages, @game_policies = paginate :game_policies, :per_page => 10
21   end
22
23   def show
24     @game_policy = GamePolicy.find(params[:id])
25   end
26
27   def new
28     @game_policy = GamePolicy.new
29   end
30
31   def create
32     @game_policy = GamePolicy.new(params[:game_policy])
33     if @game_policy.save
34       flash[:notice] = 'GamePolicy was successfully created.'
35       redirect_to :action => 'list'
36     else
37       render :action => 'new'
38     end
39   end
40
41   def edit
42     @game_policy = GamePolicy.find(params[:id])
43   end
44
45   def update
46     @game_policy = GamePolicy.find(params[:id])
47     if @game_policy.update_attributes(params[:game_policy])
48       flash[:notice] = 'GamePolicy was successfully updated.'
49       redirect_to :action => 'show', :id => @game_policy
50     else
51       render :action => 'edit'
52     end
53   end
54
55   def destroy
56     GamePolicy.find(params[:id]).destroy
57     redirect_to :action => 'list'
58   end
59 end