class ArtistsController < ApplicationController
layout 'test' if MagicNumber['test_layout']
- before_filter :authenticate_user!, :only => [:index, :show, :new, :create, :edit, :update, :destroy]
- before_filter :authenticate_author, :only => [:index, :show, :new, :create, :edit, :update, :destroy]
+ if MagicNumber['run_mode'] == 0
+ before_filter :authenticate_user, :only => [:new, :create, :edit, :update, :destroy]
+ before_filter :authenticate_author, :only => [:new, :create, :edit, :update, :destroy]
+ else
+ before_filter :authenticate_resource_reader, :only => [:index, :show, :resource_pictures]
+ before_filter :authenticate_user, :only => [:new, :create, :edit, :update, :destroy]
+ before_filter :authenticate_author, :only => [:new, :create, :edit, :update, :destroy]
+ end
before_filter :authenticate_admin!, :only => [:list, :browse]
- # GET /artists
- # GET /artists.json
def index
@page = Artist.page params[:page]
@page_size = Artist.page_size params[:page_size]
@artists = Artist.list(@page, @page_size)
respond_to do |format|
- format.html # index.html.erb
+ format.html {
+ @paginate = Artist.list_paginate(@page, @page_size)
+ render :template => 'system/filer', :locals => {
+ :items => @artists, :model => Artist,
+ :roles => [@user, @admin], :pager => @paginate
+ }
+ }
format.json { render :json => @artists.to_json(Artist.list_json_opt) }
end
end
- # GET /artists/1
- # GET /artists/1.json
def show
- @ar = Artist.show(params[:id], @author)
+ @item = Artist.show(params[:id], [@user, @admin, @demand_user])
respond_to do |format|
format.html # show.html.erb
- format.json { render :json => @ar.to_json(Artist.show_json_opt) }
+ format_prof format
+ format.json { render :json => @item.to_json(Artist.show_json_opt) }
end
end
+ def resource_pictures
+ @ar = Artist.show(params[:id], [@user, @admin, @demand_user])
+ @page = Author.page params[:page]
+ @page_size = Author.resource_picture_page_size params[:page_size]
+ @resource_pictures = ResourcePicture.himlist(@ar, @page, @page_size)
+ respond_to do |format|
+ format.html {
+ @paginate = ResourcePicture.himlist_paginate(@ar, @page, @page_size)
+ }
+ format.json { render json: @resource_pictures.to_json(ResourcePicture.list_json_opt) }
+ end
+ end
+
def count
@ar = {:count => Artist.visible_count}
respond_to do |format|
@ar.overwrite @author
respond_to do |format|
if @ar.save
- format.html { redirect_to root_path, notice: 'Artist was successfully created.' }
+ flash[:notice] = I18n.t('flash.notice.created', :model => Artist.model_name.human)
+ format.html { redirect_to root_path }
format.json { render json: @ar.to_json(Artist.show_json_opt), status: :created, location: @artist }
else
+ flash[:notice] = I18n.t('flash.notice.not_created', :model => Artist.model_name.human)
format.html { render action: "new" }
format.json { render json: @ar.errors, status: :unprocessable_entity }
end
respond_to do |format|
if @ar.save
- format.html { redirect_to '/home/configure', notice: 'Artist was successfully updated.' }
+ flash[:notice] = I18n.t('flash.notice.updated', :model => Artist.model_name.human)
+ format.html { redirect_to '/home/configure' }
format.json { head :ok }
else
+ flash[:notice] = I18n.t('flash.notice.not_updated', :model => Artist.model_name.human)
format.html { render action: "edit" }
format.json { render json: @ar.errors, status: :unprocessable_entity }
end