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)
21 render :template => 'system/filer', :locals => {
22 :items => @artists, :model => Artist,
23 :roles => [@user, @admin], :pager => @paginate
26 format.json { render :json => @artists.to_json(Artist.list_json_opt) }
31 @item = Artist.show(params[:id], [@user, @admin, @demand_user])
33 respond_to do |format|
34 format.html # show.html.erb
36 format.json { render :json => @item.to_json(Artist.show_json_opt) }
41 @ar = Artist.show(params[:id], [@user, @admin, @demand_user])
42 @page = Author.page params[:page]
43 @page_size = Author.resource_picture_page_size params[:page_size]
44 @resource_pictures = ResourcePicture.himlist(@ar, @page, @page_size)
45 respond_to do |format|
47 @paginate = ResourcePicture.himlist_paginate(@ar, @page, @page_size)
49 format.json { render json: @resource_pictures.to_json(ResourcePicture.list_json_opt) }
54 @ar = {:count => Artist.visible_count}
55 respond_to do |format|
56 format.json { render json: @ar.to_json }
63 respond_to do |format|
64 format.html { render layout: 'system' }
65 format.json { render json: @artists }
70 @ar = Artist.find(params[:id])
72 respond_to do |format|
73 format.html { render layout: 'system' }
74 format.json { render json: @ar }
79 # GET /artists/new.json
84 respond_to do |format|
85 format.html # new.html.erb
87 format.json { render json: @ar.to_json(Artist.show_json_opt) }
93 @ar = Artist.edit(params[:id], @author)
94 respond_to do |format|
105 @ar.attributes = params[:artist]
106 @ar.overwrite @author
107 respond_to do |format|
109 flash[:notice] = I18n.t('flash.notice.created', :model => Artist.model_name.human)
110 format.html { redirect_to root_path }
111 format.json { render json: @ar.to_json(Artist.show_json_opt), status: :created, location: @artist }
113 flash[:notice] = I18n.t('flash.notice.not_created', :model => Artist.model_name.human)
114 format.html { render action: "new" }
115 format.json { render json: @ar.errors, status: :unprocessable_entity }
121 # PUT /artists/1.json
123 @ar = Artist.edit(params[:id], @author)
124 @ar.attributes = params[:artist]
125 @ar.overwrite @author
127 respond_to do |format|
129 flash[:notice] = I18n.t('flash.notice.updated', :model => Artist.model_name.human)
130 format.html { redirect_to '/home/configure' }
131 format.json { head :ok }
133 flash[:notice] = I18n.t('flash.notice.not_updated', :model => Artist.model_name.human)
134 format.html { render action: "edit" }
135 format.json { render json: @ar.errors, status: :unprocessable_entity }
141 # DELETE /artists/1.json
143 @ar = Artist.edit(params[:id], @author)
146 respond_to do |format|
147 format.html { redirect_to artists_url }
148 format.json { head :ok }