X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=app%2Fcontrollers%2Fartists_controller.rb;h=4e7f96110535677bce6ef0993167b380dfab3e18;hb=9edc3731389bcae0de05ef6045cceb6b7581cc8f;hp=c46f86491ef29b5925709f8f02ad107468f47369;hpb=c75552d8db3397821ffc4913bc9e465f6141b5c5;p=pettanr%2Fpettanr.git diff --git a/app/controllers/artists_controller.rb b/app/controllers/artists_controller.rb index c46f8649..4e7f9611 100644 --- a/app/controllers/artists_controller.rb +++ b/app/controllers/artists_controller.rb @@ -1,37 +1,33 @@ class ArtistsController < ApplicationController 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] + before_action :authenticate_user, :only => [:new, :create, :edit, :update, :destroy] + before_action :authenticate_artist, :only => [: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 - - def self.model - Artist + before_action :authenticate_resource_reader, :only => [ + :index, :show + ] + before_action :authenticate_user, :only => [:new, :create, :edit, :update, :destroy] + before_action :authenticate_artist, :only => [:edit, :update, :destroy] end def index filer_list end - def show - @item = Artist.show(params[:id], @operators) + def show_html_format format + format.html { + } + end + def show + set_show respond_to do |format| - format.html { - @artist = @item - } - format_prof format - format.json { render :json => @item.to_json(Artist.show_json_opt) } + show_html_format format + show_prof_format format + show_json_format format end end - def count - list_count - end - def new form_new end @@ -41,48 +37,25 @@ class ArtistsController < ApplicationController end def create - @artist = Artist.new() - @artist.supply_default - @artist.attributes = params[:artist] - @artist.overwrite @operators - respond_to do |format| - if @artist.save - 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 + set_model + @item = @my_model_class.new + @item.supply_default + @item.attributes = @item.permit_params params + @item.overwrite @operators + render_create root_path end - + def update - @artist = Artist.edit(params[:id], @operators) - @artist.attributes = params[:artist] - @artist.overwrite @operators - - respond_to do |format| - 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 + set_edit + @item.attributes = @item.permit_params params + @item.overwrite @operators + render_update '/home/configure' end - + def destroy - @artist = Artist.edit(params[:id], @operators) - @artist.destroy - - respond_to do |format| - format.html { redirect_to artists_url } - format.json { head :ok } - end + set_model + @item = @my_model_class.edit(params[:id], @operators) + render_destroy '/home/configure' end + end