OSDN Git Service

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