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, :resource_pictures]
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 = Artist.show(params[:id], [@user, @admin, @demand_user])
40 @page = Author.page params[:page]
41 @page_size = Author.resource_picture_page_size params[:page_size]
42 @resource_pictures = ResourcePicture.mylist(@ar, @page, @page_size)
44 respond_to do |format|
45 format.html # index.html.erb
46 format.json { render json: @resource_pictures.to_json(ResourcePicture.list_json_opt) }
51 @ar = {:count => Artist.visible_count}
52 respond_to do |format|
53 format.json { render json: @ar.to_json }
60 respond_to do |format|
61 format.html { render layout: 'system' }
62 format.json { render json: @artists }
67 @ar = Artist.find(params[:id])
69 respond_to do |format|
70 format.html { render layout: 'system' }
71 format.json { render json: @ar }
76 # GET /artists/new.json
81 respond_to do |format|
82 format.html # new.html.erb
84 format.json { render json: @ar.to_json(Artist.show_json_opt) }
90 @ar = Artist.edit(params[:id], @author)
91 respond_to do |format|
102 @ar.attributes = params[:artist]
103 @ar.overwrite @author
104 respond_to do |format|
106 flash[:notice] = I18n.t('flash.notice.created', :model => Artist.model_name.human)
107 format.html { redirect_to root_path }
108 format.json { render json: @ar.to_json(Artist.show_json_opt), status: :created, location: @artist }
110 format.html { render action: "new" }
111 format.json { render json: @ar.errors, status: :unprocessable_entity }
117 # PUT /artists/1.json
119 @ar = Artist.edit(params[:id], @author)
120 @ar.attributes = params[:artist]
121 @ar.overwrite @author
123 respond_to do |format|
125 flash[:notice] = I18n.t('flash.notice.updated', :model => Artist.model_name.human)
126 format.html { redirect_to '/home/configure' }
127 format.json { head :ok }
129 format.html { render action: "edit" }
130 format.json { render json: @ar.errors, status: :unprocessable_entity }
136 # DELETE /artists/1.json
138 @ar = Artist.edit(params[:id], @author)
141 respond_to do |format|
142 format.html { redirect_to artists_url }
143 format.json { head :ok }