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]
15 set_page params @@model, params
16 @items = @@model.list(@page, @page_size)
18 respond_to do |format|
20 @paginate = @@model.list_paginate(@page, @page_size)
21 render :template => 'system/filer', :locals => {
22 :filer => @filer.window(@items, @operators, @paginate)
25 format.json { render json: @items.to_json(@@model.list_json_opt) }
30 @item = Artist.show(params[:id], @operators)
32 respond_to do |format|
37 format.json { render :json => @item.to_json(Artist.show_json_opt) }
42 @artist = Artist.show(params[:id], @operators)
43 @page = Author.page params[:page]
44 @page_size = Author.resource_picture_page_size params[:page_size]
45 @resource_pictures = ResourcePicture.himlist(@artist, @page, @page_size)
46 respond_to do |format|
48 @paginate = ResourcePicture.himlist_paginate(@artist, @page, @page_size)
50 format.json { render json: @resource_pictures.to_json(ResourcePicture.list_json_opt) }
55 @artist = {:count => Artist.visible_count}
56 respond_to do |format|
57 format.json { render json: @artist.to_json }
64 respond_to do |format|
65 format.html { render layout: 'system' }
66 format.json { render json: @artists }
71 @artist = Artist.find(params[:id])
73 respond_to do |format|
74 format.html { render layout: 'system' }
75 format.json { render json: @artist }
81 @artist.supply_default
83 respond_to do |format|
84 format.html # new.html.erb
86 format.json { render json: @artist.to_json(Artist.show_json_opt) }
91 @artist = Artist.edit(params[:id], @operators)
92 respond_to do |format|
99 @artist = Artist.new()
100 @artist.supply_default
101 @artist.attributes = params[:artist]
102 @artist.overwrite @operators
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: @artist.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: @artist.errors, status: :unprocessable_entity }
117 @artist = Artist.edit(params[:id], @operators)
118 @artist.attributes = params[:artist]
119 @artist.overwrite @operators
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 flash[:notice] = I18n.t('flash.notice.not_updated', :model => Artist.model_name.human)
128 format.html { render action: "edit" }
129 format.json { render json: @artist.errors, status: :unprocessable_entity }
135 @artist = Artist.edit(params[:id], @operators)
138 respond_to do |format|
139 format.html { redirect_to artists_url }
140 format.json { head :ok }