class ArtistsController < ApplicationController
- before_filter :authenticate_user!, :only => [:index, :show, :create, :update, :destroy]
- before_filter :authenticate_admin!, :only => [:list, :browse]
+ if Manifest.manifest.magic_numbers['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
- # GET /artists
- # GET /artists.json
+ def self.model
+ Artist
+ end
+
def index
- @artists = Artist.all
-
- respond_to do |format|
- format.html # index.html.erb
- format.json { render json: @artists }
- end
+ filer_list
end
-
- # GET /artists/1
- # GET /artists/1.json
+
+ def show_html_format format
+ format.html {
+ @artist = @item
+ }
+ end
+
def show
- @artist = Artist.find(params[:id])
-
+ set_show
respond_to do |format|
- format.html # show.html.erb
- format.json { render json: @artist }
+ show_html_format format
+ show_prof_format format
+ show_json_format format
end
end
-
- def list
- @artists = Artist.all
-
- respond_to do |format|
- format.html { render layout: 'system' }
- format.json { render json: @artists }
- end
+
+ def count
+ list_count
end
-
- def browse
- @artist = Artist.find(params[:id])
-
- respond_to do |format|
- format.html { render layout: 'system' }
- format.json { render json: @artist }
- end
- end
-
- # GET /artists/new
- # GET /artists/new.json
+
def new
- @artist = Artist.new
-
- respond_to do |format|
- format.html # new.html.erb
- format.json { render json: @artist }
- end
+ form_new
end
-
- # GET /artists/1/edit
+
def edit
- @artist = Artist.find(params[:id])
+ form_edit
end
-
- # POST /artists
- # POST /artists.json
+
def create
- @artist = Artist.new(params[:artist])
-
+ @artist = Artist.new()
+ @artist.supply_default
+ @artist.attributes = params[:artist]
+ @artist.overwrite @operators
respond_to do |format|
if @artist.save
- format.html { redirect_to @artist, notice: 'Artist was successfully created.' }
- format.json { render json: @artist, status: :created, location: @artist }
+ flash[:notice] = I18n.t('flash.notice.created', :model => Artist.model_name.human)
+ format.html { redirect_to root_path }
+ format.json { render json: @artist.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: @artist.errors, status: :unprocessable_entity }
end
end
end
- # PUT /artists/1
- # PUT /artists/1.json
def update
- @artist = Artist.find(params[:id])
+ @artist = Artist.edit(params[:id], @operators)
+ @artist.attributes = params[:artist]
+ @artist.overwrite @operators
respond_to do |format|
- if @artist.update_attributes(params[:artist])
- format.html { redirect_to @artist, notice: 'Artist was successfully updated.' }
+ if @artist.save
+ 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: @artist.errors, status: :unprocessable_entity }
end
end
end
- # DELETE /artists/1
- # DELETE /artists/1.json
def destroy
- @artist = Artist.find(params[:id])
+ @artist = Artist.edit(params[:id], @operators)
@artist.destroy
respond_to do |format|