1 class ArtistsController < ApplicationController
2 layout 'test' if MagicNumber['test_layout']
3 before_filter :authenticate_user!, :only => [:index, :show, :new, :create, :edit, :update, :destroy]
4 before_filter :authenticate_author, :only => [:index, :show, :new, :create, :edit, :update, :destroy]
5 before_filter :authenticate_admin!, :only => [:list, :browse]
10 @page = Artist.page params[:page]
11 @page_size = Artist.page_size params[:page_size]
12 @artists = Artist.list(@page, @page_size)
14 respond_to do |format|
15 format.html # index.html.erb
16 format.json { render :json => @artists.to_json(Artist.list_json_opt) }
23 @ar = Artist.show(params[:id], @author)
25 respond_to do |format|
26 format.html # show.html.erb
27 format.json { render :json => @ar.to_json(Artist.show_json_opt) }
32 @ar = {:count => Artist.visible_count}
33 respond_to do |format|
34 format.json { render json: @ar.to_json }
41 respond_to do |format|
42 format.html { render layout: 'system' }
43 format.json { render json: @artists }
48 @ar = Artist.find(params[:id])
50 respond_to do |format|
51 format.html { render layout: 'system' }
52 format.json { render json: @ar }
57 # GET /artists/new.json
62 respond_to do |format|
63 format.html # new.html.erb
65 format.json { render json: @ar.to_json(Artist.show_json_opt) }
71 @ar = Artist.edit(params[:id], @author)
72 respond_to do |format|
83 @ar.attributes = params[:artist]
85 respond_to do |format|
87 format.html { redirect_to @ar, notice: 'Artist was successfully created.' }
88 format.json { render json: @ar.to_json(Artist.show_json_opt), status: :created, location: @artist }
90 format.html { render action: "new" }
91 format.json { render json: @ar.errors, status: :unprocessable_entity }
99 @ar = Artist.edit(params[:id], @author)
100 @ar.attributes = params[:artist]
101 @ar.overwrite @author
103 respond_to do |format|
105 format.html { redirect_to @ar, notice: 'Artist was successfully updated.' }
106 format.json { head :ok }
108 format.html { render action: "edit" }
109 format.json { render json: @ar.errors, status: :unprocessable_entity }
115 # DELETE /artists/1.json
117 @ar = Artist.edit(params[:id], @author)
120 respond_to do |format|
121 format.html { redirect_to artists_url }
122 format.json { head :ok }