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]
14 @page = Artist.page params[:page]
15 @page_size = Artist.page_size params[:page_size]
16 @artists = Artist.list(@page, @page_size)
18 respond_to do |format|
20 @paginate = Artist.list_paginate(@page, @page_size)
22 format.json { render :json => @artists.to_json(Artist.list_json_opt) }
27 @ar = Artist.show(params[:id], [@user, @admin, @demand_user])
29 respond_to do |format|
30 format.html # show.html.erb
31 format.json { render :json => @ar.to_json(Artist.show_json_opt) }
36 @ar = Artist.show(params[:id], [@user, @admin, @demand_user])
37 @page = Author.page params[:page]
38 @page_size = Author.resource_picture_page_size params[:page_size]
39 @resource_pictures = ResourcePicture.himlist(@ar, @page, @page_size)
40 respond_to do |format|
42 @paginate = ResourcePicture.himlist_paginate(@ar, @page, @page_size)
44 format.json { render json: @resource_pictures.to_json(ResourcePicture.list_json_opt) }
49 @ar = {:count => Artist.visible_count}
50 respond_to do |format|
51 format.json { render json: @ar.to_json }
58 respond_to do |format|
59 format.html { render layout: 'system' }
60 format.json { render json: @artists }
65 @ar = Artist.find(params[:id])
67 respond_to do |format|
68 format.html { render layout: 'system' }
69 format.json { render json: @ar }
74 # GET /artists/new.json
79 respond_to do |format|
80 format.html # new.html.erb
82 format.json { render json: @ar.to_json(Artist.show_json_opt) }
88 @ar = Artist.edit(params[:id], @author)
89 respond_to do |format|
100 @ar.attributes = params[:artist]
101 @ar.overwrite @author
102 respond_to do |format|
104 flash[:notice] = I18n.t('flash.notice.created', :model => Artist.model_name.human)
105 format.html { redirect_to root_path }
106 format.json { render json: @ar.to_json(Artist.show_json_opt), status: :created, location: @artist }
108 format.html { render action: "new" }
109 format.json { render json: @ar.errors, status: :unprocessable_entity }
115 # PUT /artists/1.json
117 @ar = Artist.edit(params[:id], @author)
118 @ar.attributes = params[:artist]
119 @ar.overwrite @author
121 respond_to do |format|
123 flash[:notice] = I18n.t('flash.notice.updated', :model => Artist.model_name.human)
124 format.html { redirect_to '/home/configure' }
125 format.json { head :ok }
127 format.html { render action: "edit" }
128 format.json { render json: @ar.errors, status: :unprocessable_entity }
134 # DELETE /artists/1.json
136 @ar = Artist.edit(params[:id], @author)
139 respond_to do |format|
140 format.html { redirect_to artists_url }
141 format.json { head :ok }