OSDN Git Service

fix select item translation
[pettanr/pettanr.git] / app / controllers / stories_controller.rb
index bbbbc6d..22a4b19 100644 (file)
@@ -4,15 +4,11 @@ class StoriesController < ApplicationController
     before_filter :authenticate_author, :only => [:new, :create, :edit, :update, :destroy]
   else
     before_filter :authenticate_reader, :only => [
-      :index, :show, :play, :by_comic, :by_sheet, :by_author, :count, :count_by_comic, :count_by_sheet, :count_by_author
+      :index, :show, :play, :by_comic, :by_sheet, :by_author
     ]
     before_filter :authenticate_user, :only => [:new, :create, :edit, :update, :destroy]
     before_filter :authenticate_author, :only => [:new, :create, :edit, :update, :destroy]
   end
-
-  def self.model
-    Story
-  end
   
   def index
     filer_list
@@ -32,11 +28,10 @@ class StoriesController < ApplicationController
   
   def show_html_format format
     format.html {
-      play_list = Locmare::ListGroup.list 'story_sheet', 'play'
-      @play_count = play_list.count(@operators, {:id => @item.id, :my_play => @item.own?(@operators)})
-      if @operators.author
-        @new_comic_items = assist_items('comic', 'private')
-      end
+      @play_list = Locmare::ListGroup.list(
+        'story_sheets', 'by_story', @operators, 
+        {:id => @item.id, :page_size => -1}  # set no limit options
+      )
     }
   end
   
@@ -50,47 +45,21 @@ class StoriesController < ApplicationController
   end
   
   def play
-    @item = self.class.model.show(params[:id], @operators)
-    @story = @item
     set_play
-    @options = {:id => params[:id], :offset => params[:offset], :count => 1}
-    list_result = @list.open(@operators, @options)
-    @items = list_result.items
-    @count = @list.count(@operators, @options)
-    @pager = Kaminari.paginate_array(Array.new(@count, nil)).page(params[:offset]).per(1)
-    @sort_items = @list.items(@operators, 
-      {:id => params[:id], :my_play => @item.own?(@operators)},
-      0, -1
-    )
+    @list.options.merge!({'per_page' => 1})    # show one sheet
+    @list.reset
+    play_list
     respond_to do |format|
       format.html {
-        #@count = @action.list.count @item
-        #@prev_offset = @action.list.prev_offset @item
-        #@next_offset = @action.list.next_offset @item
-        if @operators.author
-          @new_sheet_items = assist_items('sheet', 'private')
+        @pager = @list.page_status.pager
+        if @item.own? @operators
+          @new_sheet_items = assist_items('home', 'sheets')
         end
       }
-      format.json { render json: @items.to_json(self.class.model.list_json_opt) }
+      list_json_format @list, format
     end
   end
   
-  def count
-    list_count
-  end
-  
-  def count_by_comic
-    list_count
-  end
-  
-  def count_by_sheet
-    list_count
-  end
-  
-  def count_by_author
-    list_count
-  end
-  
   def new
     form_new
   end