1 class ArtistsController < ApplicationController
3 before_filter :authenticate_user!, :only => [:index, :show, :new, :create, :edit, :update, :destroy]
4 before_filter :authenticate_admin!, :only => [:list, :browse]
9 @page = Artist.page params[:page]
10 @page_size = Artist.page_size params[:page_size]
11 @artists = Artist.list(@page, @page_size)
13 respond_to do |format|
14 format.html # index.html.erb
15 format.json { render :json => @artists.to_json(Artist.list_json_opt) }
22 @artist = Artist.show(params[:id], @author)
24 respond_to do |format|
25 format.html # show.html.erb
26 format.json { render :json => @artist.to_json(Artist.show_json_opt) }
31 @artist = {:count => Artist.visible_count}
32 respond_to do |format|
33 format.json { render json: @artist.to_json }
40 respond_to do |format|
41 format.html { render layout: 'system' }
42 format.json { render json: @artists }
47 @artist = Artist.find(params[:id])
49 respond_to do |format|
50 format.html { render layout: 'system' }
51 format.json { render json: @artist }
56 # GET /artists/new.json
59 @artist.supply_default
61 respond_to do |format|
62 format.html # new.html.erb
64 format.json { render json: @artist }
70 @artist = Artist.edit(params[:id], @author)
76 @artist = Artist.new()
77 @artist.supply_default
78 @artist.attributes = params[:artist]
79 @artist.overwrite @author
80 respond_to do |format|
82 format.html { redirect_to @artist, notice: 'Artist was successfully created.' }
83 format.json { render json: @artist, status: :created, location: @artist }
85 format.html { render action: "new" }
86 format.json { render json: @artist.errors, status: :unprocessable_entity }
94 @artist = Artist.edit(params[:id], @author)
95 @artist.attributes = params[:artist]
96 @artist.overwrite @author
98 respond_to do |format|
100 format.html { redirect_to @artist, notice: 'Artist was successfully updated.' }
101 format.json { head :ok }
103 format.html { render action: "edit" }
104 format.json { render json: @artist.errors, status: :unprocessable_entity }
110 # DELETE /artists/1.json
112 @artist = Artist.edit(params[:id], @author)
115 respond_to do |format|
116 format.html { redirect_to artists_url }
117 format.json { head :ok }