OSDN Git Service

fix: any
[pettanr/pettanr.git] / app / controllers / story_sheets_controller.rb
index c1b74e0..793bb6e 100644 (file)
@@ -1,13 +1,13 @@
 class StorySheetsController < 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_author, :only => [:new, :create, :edit, :update, :destroy]
   else
-    before_filter :authenticate_reader, :only => [
-      :index, :show, :by_story, :by_sheet, :by_author, :count, :count_by_story, :count_by_sheet, :count_by_author
+    before_action :authenticate_reader, :only => [
+      :index, :show, :by_story, :by_sheet, :by_author
     ]
-    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_author, :only => [:new, :create, :edit, :update, :destroy]
   end
   
   def index
@@ -15,15 +15,15 @@ class StorySheetsController < ApplicationController
   end
   
   def by_story
-    filer_list
+    filer_list param: params[:id]
   end
   
   def by_sheet
-    filer_list
+    filer_list param: params[:id]
   end
   
   def by_author
-    filer_list
+    filer_list param: params[:id]
   end
   
   def show
@@ -34,22 +34,6 @@ class StorySheetsController < ApplicationController
     end
   end
   
-  def count
-    list_count
-  end
-  
-  def count_by_story
-    list_count
-  end
-  
-  def count_by_sheet
-    list_count
-  end
-  
-  def count_by_author
-    list_count
-  end
-  
   def new
     form_new
   end
@@ -59,44 +43,36 @@ class StorySheetsController < ApplicationController
   end
   
   def create
-    @my_model_class = self.class.model
+    set_model
     @item = @my_model_class.new
     @item.supply_default
-    @item.attributes = params[@item.item_name]
+    @item.attributes = @item.permit_params params
     @item.overwrite @operators
     @binder = @my_model_class.binder_model.edit(@item.binder_id, @operators) if @item.binder_id
     @panel = @my_model_class.destination_model.show(@item.destination_id, @operators) if @item.destination_id
     
-    leaf_render_create play_scroll_path(@binder)
+    leaf_render_create play_story_path(@binder)
   end
   
   def update
-    @my_model_class = self.class.model
+    set_model
     @item = @my_model_class.edit(params[:id], @operators)
     ot = @item.t
-    @item.attributes = params[@item.item_name]
+    @item.attributes = @item.permit_params params
     @item.overwrite @operators
     @binder = @my_model_class.binder_model.edit(@item.binder_id, @operators) if @item.binder_id
     # no check permission for destination
     # swapable hidden panel
     #@panel = @my_model_class.destination_model.show(@item.destination_id, @operators) if @item.destination_id
     
-    leaf_render_update ot, play_scroll_path(@binder)
+    leaf_render_update ot, play_story_path(@binder)
   end
   
   def destroy
-    @story_sheet = StorySheet.edit(params[:id], @operators)
-    @story = Story.edit(@story_sheet.story_id, @operators) if @story_sheet.story_id
-    respond_to do |format|
-      if @story_sheet.destroy_and_shorten
-        flash[:notice] = I18n.t('flash.notice.destroyed', :model => StorySheet.model_name.human)
-        format.html { redirect_to play_story_path(@story) }
-        format.json { head :ok }
-      else
-        flash[:notice] = I18n.t('flash.notice.not_destroyed', :model => StorySheet.model_name.human)
-        format.html { redirect_to story_sheet_path(@story_sheet) }
-        format.json { render json: @story_sheet.errors, status: :unprocessable_entity }
-      end
-    end
+    set_model
+    @item = @my_model_class.edit(params[:id], @operators)
+    @binder = @my_model_class.binder_model.edit(@item.binder_id, @operators) if @item.binder_id
+    render_destroy play_story_path(@binder)
   end
+  
 end