OSDN Git Service

t#30143:au and ar change
[pettanr/pettanr.git] / app / controllers / artists_controller.rb
index aab67cb..acd5fa2 100644 (file)
@@ -1,6 +1,7 @@
 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]
   before_filter :authenticate_admin!, :only => [:list, :browse]
 
   # GET /artists
@@ -19,18 +20,18 @@ class ArtistsController < ApplicationController
   # GET /artists/1
   # GET /artists/1.json
   def show
-    @artist = Artist.show(params[:id], @author)
+    @ar = Artist.show(params[:id], @author)
 
     respond_to do |format|
       format.html # show.html.erb
-      format.json { render :json => @artist.to_json(Artist.show_json_opt) }
+      format.json { render :json => @ar.to_json(Artist.show_json_opt) }
     end
   end
 
   def count
-    @artist = {:count => Artist.visible_count}
+    @ar = {:count => Artist.visible_count}
     respond_to do |format|
-      format.json { render json: @artist.to_json }
+      format.json { render json: @ar.to_json }
     end
   end
   
@@ -44,30 +45,30 @@ class ArtistsController < ApplicationController
   end
 
   def browse
-    @artist = Artist.find(params[:id])
+    @ar = Artist.find(params[:id])
 
     respond_to do |format|
       format.html { render layout: 'system' }
-      format.json { render json: @artist }
+      format.json { render json: @ar }
     end
   end
 
   # GET /artists/new
   # GET /artists/new.json
   def new
-    @artist = Artist.new
-    @artist.supply_default 
+    @ar = Artist.new
+    @ar.supply_default 
 
     respond_to do |format|
       format.html # new.html.erb
       format.js
-      format.json { render json: @artist.to_json(Artist.show_json_opt) }
+      format.json { render json: @ar.to_json(Artist.show_json_opt) }
     end
   end
 
   # GET /artists/1/edit
   def edit
-    @artist = Artist.edit(params[:id], @author)
+    @ar = Artist.edit(params[:id], @author)
     respond_to do |format|
       format.html 
       format.js
@@ -77,17 +78,17 @@ class ArtistsController < ApplicationController
   # POST /artists
   # POST /artists.json
   def create
-    @artist = Artist.new()
-    @artist.supply_default 
-    @artist.attributes = params[:artist]
-    @artist.overwrite @author
+    @ar = Artist.new()
+    @ar.supply_default 
+    @ar.attributes = params[:artist]
+    @ar.overwrite @author
     respond_to do |format|
-      if @artist.save
-        format.html { redirect_to @artist, notice: 'Artist was successfully created.' }
-        format.json { render json: @artist.to_json(Artist.show_json_opt), status: :created, location: @artist }
+      if @ar.save
+        format.html { redirect_to root_path, notice: 'Artist was successfully created.' }
+        format.json { render json: @ar.to_json(Artist.show_json_opt), status: :created, location: @artist }
       else
         format.html { render action: "new" }
-        format.json { render json: @artist.errors, status: :unprocessable_entity }
+        format.json { render json: @ar.errors, status: :unprocessable_entity }
       end
     end
   end
@@ -95,17 +96,17 @@ class ArtistsController < ApplicationController
   # PUT /artists/1
   # PUT /artists/1.json
   def update
-    @artist = Artist.edit(params[:id], @author)
-    @artist.attributes = params[:artist]
-    @artist.overwrite @author
+    @ar = Artist.edit(params[:id], @author)
+    @ar.attributes = params[:artist]
+    @ar.overwrite @author
 
     respond_to do |format|
-      if @artist.save
-        format.html { redirect_to @artist, notice: 'Artist was successfully updated.' }
+      if @ar.save
+        format.html { redirect_to '/home/configure', notice: 'Artist was successfully updated.' }
         format.json { head :ok }
       else
         format.html { render action: "edit" }
-        format.json { render json: @artist.errors, status: :unprocessable_entity }
+        format.json { render json: @ar.errors, status: :unprocessable_entity }
       end
     end
   end
@@ -113,8 +114,8 @@ class ArtistsController < ApplicationController
   # DELETE /artists/1
   # DELETE /artists/1.json
   def destroy
-    @artist = Artist.edit(params[:id], @author)
-    @artist.destroy
+    @ar = Artist.edit(params[:id], @author)
+    @ar.destroy
 
     respond_to do |format|
       format.html { redirect_to artists_url }