OSDN Git Service

t#:
[pettanr/pettanr.git] / app / controllers / panel_pictures_controller.rb
index 1a23777..cf55a8f 100644 (file)
@@ -8,7 +8,6 @@ class PanelPicturesController < ApplicationController
     before_filter :authenticate_user, :only => [:new, :edit, :create, :update, :destroy]
     before_filter :authenticate_author, :only => [:new, :edit, :create, :update, :destroy]
   end
-  before_filter :authenticate_admin!, :only => [:list, :browse]
 
   def self.model
     PanelPicture
@@ -30,29 +29,11 @@ class PanelPicturesController < ApplicationController
     end
   end
 
-  def list
-    @panel_pictures = PanelPicture.all
-
-    respond_to do |format|
-      format.html { render layout: 'system' }
-      format.json { render json: @panel_pictures }
-    end
-  end
-
-  def browse
-    @panel_picture = PanelPicture.find(params[:id])
-
-    respond_to do |format|
-      format.html { render layout: 'system' }
-      format.json { render json: @panel_picture}
-    end
-  end
-
   def new
-    raise Pettanr::NotWork unless @author.working_panel
-    @picture = Picture.show params[:picture_id], @author
+    raise Pettanr::NotWork unless @operators.author.working_panel
+    @picture = Picture.show params[:picture_id], @operators
     raise ActiveRecord::Forbidden unless @picture.enable?
-    @panel = Panel.edit(@author.working_panel, @author)
+    @panel = Panel.edit(@operators.author.working_panel, @operators)
     
     @panel_picture = PanelPicture.new :panel_id => @panel.id, :picture_id => @picture.id
     @panel_picture.supply_default
@@ -64,8 +45,8 @@ class PanelPicturesController < ApplicationController
   end
 
   def edit
-    @panel_picture = PanelPicture.show(params[:id], @author)
-    @panel = Panel.edit(@panel_picture.panel.id, @author)
+    @panel_picture = PanelPicture.show(params[:id], @operators)
+    @panel = Panel.edit(@panel_picture.panel.id, @operators)
     
     respond_to do |format|
       format.html
@@ -74,18 +55,18 @@ class PanelPicturesController < ApplicationController
 
   def create
     raise Pettanr::NotWork unless @author.working_panel
-    @panel = Panel.edit(@author.working_panel, @author)
+    @panel = Panel.edit(@operators.author.working_panel, @operators)
     
     @panel_picture = PanelPicture.new 
     @panel_picture.attributes = params[:panel_picture]
     @panel_picture.overwrite @panel.id
     
-    @picture = Picture.show @panel_picture.picture_id, @author
+    @picture = Picture.show @panel_picture.picture_id, @operators
     raise ActiveRecord::Forbidden unless @picture.enable?
     
     respond_to do |format|
       if @panel_picture.valid?
-        if @panel_picture.store @author
+        if @panel_picture.store @operators
           flash[:notice] = I18n.t('flash.notice.created', :model => Panel.model_name.human)
           format.html { redirect_to @panel }
           format.json { render json: @panel.panel_elements_as_json, status: :created, location: @panel }
@@ -103,16 +84,16 @@ class PanelPicturesController < ApplicationController
   end
 
   def update
-    @panel_picture = PanelPicture.show(params[:id], @author)
+    @panel_picture = PanelPicture.show(params[:id], @operators)
     @panel_picture.attributes = params[:panel_picture]
-    @panel = Panel.edit(@panel_picture.panel.id, @author)
+    @panel = Panel.edit(@panel_picture.panel.id, @operators)
     @panel_picture.overwrite @panel.id
     
-    @picture = Picture.show @panel_picture.picture_id, @author
+    @picture = Picture.show @panel_picture.picture_id, @operators
     raise ActiveRecord::Forbidden unless @picture.enable?
     
     respond_to do |format|
-      if @panel_picture.store @author
+      if @panel_picture.store @operators
         flash[:notice] = I18n.t('flash.notice.updated', :model => PanelPicture.model_name.human)
         format.html { redirect_to @panel_picture }
         format.json { head :ok }
@@ -125,11 +106,11 @@ class PanelPicturesController < ApplicationController
   end
 
   def destroy
-    @panel_picture = PanelPicture.show(params[:id], @author)
-    @panel = Panel.edit(@panel_picture.panel.id, @author)
+    @panel_picture = PanelPicture.show(params[:id], @operators)
+    @panel = Panel.edit(@panel_picture.panel.id, @operators)
     
     respond_to do |format|
-      if @panel_picture.remove @author
+      if @panel_picture.remove @operators
         flash[:notice] = I18n.t('flash.notice.destroyed', :model => PanelPicture.model_name.human)
         format.html { redirect_to @panel }
         format.json { head :ok }