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]
17 respond_to do |format|
19 format.json { render json: @items.to_json(@@model.list_json_opt) }
24 @item = Artist.show(params[:id], @operators)
26 respond_to do |format|
31 format.json { render :json => @item.to_json(Artist.show_json_opt) }
36 @artist = Artist.show(params[:id], @operators)
37 @page = Author.page params[:page]
38 @page_size = Author.resource_picture_page_size params[:page_size]
39 @resource_pictures = ResourcePicture.himlist(@artist, @page, @page_size)
40 respond_to do |format|
42 @paginate = ResourcePicture.himlist_paginate(@artist, @page, @page_size)
44 format.json { render json: @resource_pictures.to_json(ResourcePicture.list_json_opt) }
49 @artist = {:count => Artist.visible_count}
50 respond_to do |format|
51 format.json { render json: @artist.to_json }
58 respond_to do |format|
59 format.html { render layout: 'system' }
60 format.json { render json: @artists }
65 @artist = Artist.find(params[:id])
67 respond_to do |format|
68 format.html { render layout: 'system' }
69 format.json { render json: @artist }
75 @artist.supply_default
77 respond_to do |format|
78 format.html # new.html.erb
80 format.json { render json: @artist.to_json(Artist.show_json_opt) }
85 @artist = Artist.edit(params[:id], @operators)
86 respond_to do |format|
93 @artist = Artist.new()
94 @artist.supply_default
95 @artist.attributes = params[:artist]
96 @artist.overwrite @operators
97 respond_to do |format|
99 flash[:notice] = I18n.t('flash.notice.created', :model => Artist.model_name.human)
100 format.html { redirect_to root_path }
101 format.json { render json: @artist.to_json(Artist.show_json_opt), status: :created, location: @artist }
103 flash[:notice] = I18n.t('flash.notice.not_created', :model => Artist.model_name.human)
104 format.html { render action: "new" }
105 format.json { render json: @artist.errors, status: :unprocessable_entity }
111 @artist = Artist.edit(params[:id], @operators)
112 @artist.attributes = params[:artist]
113 @artist.overwrite @operators
115 respond_to do |format|
117 flash[:notice] = I18n.t('flash.notice.updated', :model => Artist.model_name.human)
118 format.html { redirect_to '/home/configure' }
119 format.json { head :ok }
121 flash[:notice] = I18n.t('flash.notice.not_updated', :model => Artist.model_name.human)
122 format.html { render action: "edit" }
123 format.json { render json: @artist.errors, status: :unprocessable_entity }
129 @artist = Artist.edit(params[:id], @operators)
132 respond_to do |format|
133 format.html { redirect_to artists_url }
134 format.json { head :ok }