1 class ArtistsController < ApplicationController
2 layout 'test' if MagicNumber['test_layout']
3 if MagicNumber['run_mode'] == 0
4 before_filter :authenticate_user!, :only => [:new, :create, :edit, :update, :destroy]
5 before_filter :authenticate_author, :only => [:new, :create, :edit, :update, :destroy]
7 before_filter :authenticate_user!, :only => [:index, :show, :new, :create, :edit, :update, :destroy]
8 before_filter :authenticate_author, :only => [:index, :show, :new, :create, :edit, :update, :destroy]
10 before_filter :authenticate_admin!, :only => [:list, :browse]
15 @page = Artist.page params[:page]
16 @page_size = Artist.page_size params[:page_size]
17 @artists = Artist.list(@page, @page_size)
19 respond_to do |format|
20 format.html # index.html.erb
21 format.json { render :json => @artists.to_json(Artist.list_json_opt) }
28 @ar = Artist.show(params[:id], @author)
30 respond_to do |format|
31 format.html # show.html.erb
32 format.json { render :json => @ar.to_json(Artist.show_json_opt) }
37 @ar = {:count => Artist.visible_count}
38 respond_to do |format|
39 format.json { render json: @ar.to_json }
46 respond_to do |format|
47 format.html { render layout: 'system' }
48 format.json { render json: @artists }
53 @ar = Artist.find(params[:id])
55 respond_to do |format|
56 format.html { render layout: 'system' }
57 format.json { render json: @ar }
62 # GET /artists/new.json
67 respond_to do |format|
68 format.html # new.html.erb
70 format.json { render json: @ar.to_json(Artist.show_json_opt) }
76 @ar = Artist.edit(params[:id], @author)
77 respond_to do |format|
88 @ar.attributes = params[:artist]
90 respond_to do |format|
92 flash[:notice] = I18n.t('flash.notice.created', :model => Artist.model_name.human)
93 format.html { redirect_to root_path }
94 format.json { render json: @ar.to_json(Artist.show_json_opt), status: :created, location: @artist }
96 format.html { render action: "new" }
97 format.json { render json: @ar.errors, status: :unprocessable_entity }
103 # PUT /artists/1.json
105 @ar = Artist.edit(params[:id], @author)
106 @ar.attributes = params[:artist]
107 @ar.overwrite @author
109 respond_to do |format|
111 flash[:notice] = I18n.t('flash.notice.updated', :model => Artist.model_name.human)
112 format.html { redirect_to '/home/configure' }
113 format.json { head :ok }
115 format.html { render action: "edit" }
116 format.json { render json: @ar.errors, status: :unprocessable_entity }
122 # DELETE /artists/1.json
124 @ar = Artist.edit(params[:id], @author)
127 respond_to do |format|
128 format.html { redirect_to artists_url }
129 format.json { head :ok }