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.prof { render :template => 'top/prof', :layout => true }
32 format.json { render :json => @ar.to_json(Artist.show_json_opt) }
37 @ar = Artist.show(params[:id], [@user, @admin, @demand_user])
38 @page = Author.page params[:page]
39 @page_size = Author.resource_picture_page_size params[:page_size]
40 @resource_pictures = ResourcePicture.himlist(@ar, @page, @page_size)
41 respond_to do |format|
43 @paginate = ResourcePicture.himlist_paginate(@ar, @page, @page_size)
45 format.json { render json: @resource_pictures.to_json(ResourcePicture.list_json_opt) }
50 @ar = {:count => Artist.visible_count}
51 respond_to do |format|
52 format.json { render json: @ar.to_json }
59 respond_to do |format|
60 format.html { render layout: 'system' }
61 format.json { render json: @artists }
66 @ar = Artist.find(params[:id])
68 respond_to do |format|
69 format.html { render layout: 'system' }
70 format.json { render json: @ar }
75 # GET /artists/new.json
80 respond_to do |format|
81 format.html # new.html.erb
83 format.json { render json: @ar.to_json(Artist.show_json_opt) }
89 @ar = Artist.edit(params[:id], @author)
90 respond_to do |format|
101 @ar.attributes = params[:artist]
102 @ar.overwrite @author
103 respond_to do |format|
105 flash[:notice] = I18n.t('flash.notice.created', :model => Artist.model_name.human)
106 format.html { redirect_to root_path }
107 format.json { render json: @ar.to_json(Artist.show_json_opt), status: :created, location: @artist }
109 flash[:notice] = I18n.t('flash.notice.not_created', :model => Artist.model_name.human)
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 flash[:notice] = I18n.t('flash.notice.not_updated', :model => Artist.model_name.human)
130 format.html { render action: "edit" }
131 format.json { render json: @ar.errors, status: :unprocessable_entity }
137 # DELETE /artists/1.json
139 @ar = Artist.edit(params[:id], @author)
142 respond_to do |format|
143 format.html { redirect_to artists_url }
144 format.json { head :ok }