OSDN Git Service

t#31056:add diff import
[pettanr/pettanr.git] / app / controllers / artists_controller.rb
index acd5fa2..032a98a 100644 (file)
@@ -1,7 +1,13 @@
 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]
+    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
@@ -20,7 +26,7 @@ class ArtistsController < ApplicationController
   # GET /artists/1
   # GET /artists/1.json
   def show
-    @ar = Artist.show(params[:id], @author)
+    @ar = Artist.show(params[:id], [@user, @admin, @demand_user])
 
     respond_to do |format|
       format.html # show.html.erb
@@ -84,7 +90,8 @@ class ArtistsController < ApplicationController
     @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
         format.html { render action: "new" }
@@ -102,7 +109,8 @@ class ArtistsController < ApplicationController
 
     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
         format.html { render action: "edit" }