Description:
[web] disable sites_controller from normal users
git-svn-id: http://theory.cpe.ku.ac.th/grader/web/trunk@247 6386c4cd-e34a-4fa8-8920-d93eb39b512e
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r119:cf9b6fbe5680 - - 1 file changed: 3 inserted, 0 deleted
@@ -1,87 +1,90 | |||||
|
1 | class SitesController < ApplicationController |
|
1 | class SitesController < ApplicationController |
|
|
2 | + | ||
|
|
3 | + before_filter :admin_authorization | ||
|
|
4 | + | ||
|
2 | # GET /sites |
|
5 | # GET /sites |
|
3 | # GET /sites.xml |
|
6 | # GET /sites.xml |
|
4 | def index |
|
7 | def index |
|
5 | @sites = Site.find(:all) |
|
8 | @sites = Site.find(:all) |
|
6 |
|
9 | ||
|
7 | respond_to do |format| |
|
10 | respond_to do |format| |
|
8 | format.html # index.html.erb |
|
11 | format.html # index.html.erb |
|
9 | format.xml { render :xml => @sites } |
|
12 | format.xml { render :xml => @sites } |
|
10 | end |
|
13 | end |
|
11 | end |
|
14 | end |
|
12 |
|
15 | ||
|
13 | # GET /sites/1 |
|
16 | # GET /sites/1 |
|
14 | # GET /sites/1.xml |
|
17 | # GET /sites/1.xml |
|
15 | def show |
|
18 | def show |
|
16 | @site = Site.find(params[:id]) |
|
19 | @site = Site.find(params[:id]) |
|
17 |
|
20 | ||
|
18 | respond_to do |format| |
|
21 | respond_to do |format| |
|
19 | format.html # show.html.erb |
|
22 | format.html # show.html.erb |
|
20 | format.xml { render :xml => @site } |
|
23 | format.xml { render :xml => @site } |
|
21 | end |
|
24 | end |
|
22 | end |
|
25 | end |
|
23 |
|
26 | ||
|
24 | # GET /sites/new |
|
27 | # GET /sites/new |
|
25 | # GET /sites/new.xml |
|
28 | # GET /sites/new.xml |
|
26 | def new |
|
29 | def new |
|
27 | @site = Site.new |
|
30 | @site = Site.new |
|
28 |
|
31 | ||
|
29 | respond_to do |format| |
|
32 | respond_to do |format| |
|
30 | format.html # new.html.erb |
|
33 | format.html # new.html.erb |
|
31 | format.xml { render :xml => @site } |
|
34 | format.xml { render :xml => @site } |
|
32 | end |
|
35 | end |
|
33 | end |
|
36 | end |
|
34 |
|
37 | ||
|
35 | # GET /sites/1/edit |
|
38 | # GET /sites/1/edit |
|
36 | def edit |
|
39 | def edit |
|
37 | @site = Site.find(params[:id]) |
|
40 | @site = Site.find(params[:id]) |
|
38 | end |
|
41 | end |
|
39 |
|
42 | ||
|
40 | # POST /sites |
|
43 | # POST /sites |
|
41 | # POST /sites.xml |
|
44 | # POST /sites.xml |
|
42 | def create |
|
45 | def create |
|
43 | @site = Site.new(params[:site]) |
|
46 | @site = Site.new(params[:site]) |
|
44 | @site.clear_start_time_if_not_started |
|
47 | @site.clear_start_time_if_not_started |
|
45 |
|
48 | ||
|
46 | respond_to do |format| |
|
49 | respond_to do |format| |
|
47 | if @site.save |
|
50 | if @site.save |
|
48 | flash[:notice] = 'Site was successfully created.' |
|
51 | flash[:notice] = 'Site was successfully created.' |
|
49 | format.html { redirect_to(@site) } |
|
52 | format.html { redirect_to(@site) } |
|
50 | format.xml { render :xml => @site, :status => :created, :location => @site } |
|
53 | format.xml { render :xml => @site, :status => :created, :location => @site } |
|
51 | else |
|
54 | else |
|
52 | format.html { render :action => "new" } |
|
55 | format.html { render :action => "new" } |
|
53 | format.xml { render :xml => @site.errors, :status => :unprocessable_entity } |
|
56 | format.xml { render :xml => @site.errors, :status => :unprocessable_entity } |
|
54 | end |
|
57 | end |
|
55 | end |
|
58 | end |
|
56 | end |
|
59 | end |
|
57 |
|
60 | ||
|
58 | # PUT /sites/1 |
|
61 | # PUT /sites/1 |
|
59 | # PUT /sites/1.xml |
|
62 | # PUT /sites/1.xml |
|
60 | def update |
|
63 | def update |
|
61 | @site = Site.find(params[:id]) |
|
64 | @site = Site.find(params[:id]) |
|
62 | @site.clear_start_time_if_not_started |
|
65 | @site.clear_start_time_if_not_started |
|
63 |
|
66 | ||
|
64 | respond_to do |format| |
|
67 | respond_to do |format| |
|
65 | if @site.update_attributes(params[:site]) |
|
68 | if @site.update_attributes(params[:site]) |
|
66 | flash[:notice] = 'Site was successfully updated.' |
|
69 | flash[:notice] = 'Site was successfully updated.' |
|
67 | format.html { redirect_to(@site) } |
|
70 | format.html { redirect_to(@site) } |
|
68 | format.xml { head :ok } |
|
71 | format.xml { head :ok } |
|
69 | else |
|
72 | else |
|
70 | format.html { render :action => "edit" } |
|
73 | format.html { render :action => "edit" } |
|
71 | format.xml { render :xml => @site.errors, :status => :unprocessable_entity } |
|
74 | format.xml { render :xml => @site.errors, :status => :unprocessable_entity } |
|
72 | end |
|
75 | end |
|
73 | end |
|
76 | end |
|
74 | end |
|
77 | end |
|
75 |
|
78 | ||
|
76 | # DELETE /sites/1 |
|
79 | # DELETE /sites/1 |
|
77 | # DELETE /sites/1.xml |
|
80 | # DELETE /sites/1.xml |
|
78 | def destroy |
|
81 | def destroy |
|
79 | @site = Site.find(params[:id]) |
|
82 | @site = Site.find(params[:id]) |
|
80 | @site.destroy |
|
83 | @site.destroy |
|
81 |
|
84 | ||
|
82 | respond_to do |format| |
|
85 | respond_to do |format| |
|
83 | format.html { redirect_to(sites_url) } |
|
86 | format.html { redirect_to(sites_url) } |
|
84 | format.xml { head :ok } |
|
87 | format.xml { head :ok } |
|
85 | end |
|
88 | end |
|
86 | end |
|
89 | end |
|
87 | end |
|
90 | end |
You need to be logged in to leave comments.
Login now