OSDN Git Service

fix: fetch fail
[pettanr/pettanr.git] / app / controllers / original_pictures_controller.rb
index c902cf9..8246a63 100644 (file)
@@ -1,11 +1,11 @@
 #原画
 class OriginalPicturesController < ApplicationController
-  before_filter :authenticate_reader, :only => [:show, :history]
-  before_filter :authenticate_user, :only => [:index, :new, :edit, :create, :update, :destroy]
-  before_filter :authenticate_artist, :only => [:index, :new, :edit, :create, :update, :destroy]
+  before_action :authenticate_reader, :only => [:show, :history]
+  before_action :authenticate_user, :only => [:index, :new, :edit, :create, :update, :destroy]
+  before_action :authenticate_artist, :only => [:index, :new, :edit, :create, :update, :destroy]
   
   def index
-    filer_list
+    filer_list param: @operators
   end
 
   def show_html_format format
@@ -34,14 +34,14 @@ class OriginalPicturesController < ApplicationController
       show_json_format format
     end
   end
-
+  
   def history
     set_show
-    @history = @item.history
+    @finder = @my_action.finder(param: params[:id]).page(1).per(-1)
     
     respond_to do |format|
       format.html
-      format.json { render json: @history.to_json }
+      list_json_format @finder, format
     end
   end
   
@@ -63,7 +63,6 @@ class OriginalPicturesController < ApplicationController
   
   def create
     set_model
-    p  params[:file]
     @imager = if params[:original_picture]
       PettanImager.load set_image params[:original_picture][:file]
     else
@@ -106,16 +105,9 @@ class OriginalPicturesController < ApplicationController
   end
   
   def destroy
-    @item = OriginalPicture.edit(params[:id], @operators)
-    
-    respond_to do |format|
-      if @item.destroy_with_resource_picture
-        format.html { redirect_to original_pictures_url }
-        format.json { head :ok }
-      else
-        format.html { redirect_to original_picture_path(@item) }
-        format.json { render json: @item.errors, status: :unprocessable_entity }
-      end
-    end
+    set_model
+    @item = @my_model_class.edit(params[:id], @operators)
+    render_destroy_by 'destroy_with_resource_picture', original_pictures_url
   end
+  
 end