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_resource_reader, :only => [:index, :show]
8 before_filter :authenticate_user, :only => [:new, :create, :edit, :update, :destroy]
9 before_filter :authenticate_author, :only => [:new, :create, :edit, :update, :destroy]
11 before_filter :authenticate_admin!, :only => [:list, :browse]
16 @page = Artist.page params[:page]
17 @page_size = Artist.page_size params[:page_size]
18 @artists = Artist.list(@page, @page_size)
20 respond_to do |format|
21 format.html # index.html.erb
22 format.json { render :json => @artists.to_json(Artist.list_json_opt) }
29 @ar = Artist.show(params[:id], [@user, @admin, @demand_user])
31 respond_to do |format|
32 format.html # show.html.erb
33 format.json { render :json => @ar.to_json(Artist.show_json_opt) }
38 @ar = {:count => Artist.visible_count}
39 respond_to do |format|
40 format.json { render json: @ar.to_json }
47 respond_to do |format|
48 format.html { render layout: 'system' }
49 format.json { render json: @artists }
54 @ar = Artist.find(params[:id])
56 respond_to do |format|
57 format.html { render layout: 'system' }
58 format.json { render json: @ar }
63 # GET /artists/new.json
68 respond_to do |format|
69 format.html # new.html.erb
71 format.json { render json: @ar.to_json(Artist.show_json_opt) }
77 @ar = Artist.edit(params[:id], @author)
78 respond_to do |format|
89 @ar.attributes = params[:artist]
91 respond_to do |format|
93 flash[:notice] = I18n.t('flash.notice.created', :model => Artist.model_name.human)
94 format.html { redirect_to root_path }
95 format.json { render json: @ar.to_json(Artist.show_json_opt), status: :created, location: @artist }
97 format.html { render action: "new" }
98 format.json { render json: @ar.errors, status: :unprocessable_entity }
104 # PUT /artists/1.json
106 @ar = Artist.edit(params[:id], @author)
107 @ar.attributes = params[:artist]
108 @ar.overwrite @author
110 respond_to do |format|
112 flash[:notice] = I18n.t('flash.notice.updated', :model => Artist.model_name.human)
113 format.html { redirect_to '/home/configure' }
114 format.json { head :ok }
116 format.html { render action: "edit" }
117 format.json { render json: @ar.errors, status: :unprocessable_entity }
123 # DELETE /artists/1.json
125 @ar = Artist.edit(params[:id], @author)
128 respond_to do |format|
129 format.html { redirect_to artists_url }
130 format.json { head :ok }