OSDN Git Service

927e460dffa6b778c6711d8bbc878693271fb9c9
[pettanr/pettanr.git] / app / controllers / common_lisences_controller.rb
1 class CommonLisencesController < ApplicationController
2   before_filter :authenticate_author!, :only => [:index, :show]
3   before_filter :authenticate_admin!, :only => [:list, :browse, :new, :edit, :create, :update, :destroy]
4
5   # GET /common_lisences
6   # GET /common_lisences.json
7   def index
8     @common_lisences = CommonLisence.all
9
10     respond_to do |format|
11       format.html # index.html.erb
12       format.json { render json: @common_lisences }
13     end
14   end
15
16   # GET /common_lisences/1
17   # GET /common_lisences/1.json
18   def show
19     @common_lisence = CommonLisence.find(params[:id])
20
21     respond_to do |format|
22       format.html # show.html.erb
23       format.json { render json: @common_lisence }
24     end
25   end
26
27   def list
28     @common_lisences = CommonLisence.all
29
30     respond_to do |format|
31       format.html { render layout: 'system' }
32       format.json { render json: @common_lisences }
33     end
34   end
35
36   def browse
37     @common_lisence = CommonLisence.find(params[:id])
38
39     respond_to do |format|
40       format.html { render layout: 'system' }
41       format.json { render json: @common_lisence }
42     end
43   end
44
45   # GET /common_lisences/new
46   # GET /common_lisences/new.json
47   def new
48     @common_lisence = CommonLisence.new
49
50     respond_to do |format|
51       format.html # new.html.erb
52       format.json { render json: @common_lisence }
53     end
54   end
55
56   # GET /common_lisences/1/edit
57   def edit
58     @common_lisence = CommonLisence.find(params[:id])
59   end
60
61   # POST /common_lisences
62   # POST /common_lisences.json
63   def create
64     @common_lisence = CommonLisence.new(params[:common_lisence])
65
66     respond_to do |format|
67       CommonLisence.transaction do
68         if @common_lisence.save_save
69           format.html { redirect_to :action => :browse, :id => @common_lisence.id, notice: 'Common lisence was successfully created.' }
70           format.json { render json: @common_lisence, status: :created, location: @common_lisence }
71         else
72           format.html { render action: "new" }
73           format.json { render json: @common_lisence.errors, status: :unprocessable_entity }
74         end
75       end
76     end
77   end
78
79   # PUT /common_lisences/1
80   # PUT /common_lisences/1.json
81   def update
82     @common_lisence = CommonLisence.find(params[:id])
83
84     respond_to do |format|
85       if @common_lisence.update_attributes(params[:common_lisence])
86         format.html { redirect_to :action => :browse, :id => @common_lisence.id, notice: 'Common lisence was successfully updated.' }
87         format.json { head :ok }
88       else
89         format.html { render action: "edit" }
90         format.json { render json: @common_lisence.errors, status: :unprocessable_entity }
91       end
92     end
93   end
94
95   # DELETE /common_lisences/1
96   # DELETE /common_lisences/1.json
97   def destroy
98     @common_lisence = CommonLisence.find(params[:id])
99     @common_lisence.destroy
100
101     respond_to do |format|
102       format.html { redirect_to common_lisences_url }
103       format.json { head :ok }
104     end
105   end
106 end