OSDN Git Service

fix: local manifest/add helper
[pettanr/pettanr.git] / app / controllers / scrolls_controller.rb
index 5c933c5..f95ade4 100644 (file)
@@ -4,16 +4,12 @@ class ScrollsController < ApplicationController
     before_filter :authenticate_author, :only => [:new, :create, :edit, :update, :destroy]
   else
     before_filter :authenticate_reader, :only => [
-      :top, :index, :show, :play, :by_panel, :by_author, :count, :count_by_panel, :count_by_author
+      :top, :index, :show, :play, :by_panel, :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
-    Scroll
-  end
-  
   def index
     filer_list
   end
@@ -28,9 +24,9 @@ class ScrollsController < ApplicationController
   
   def show_html_format format
     format.html {
-      play_list = Locmare::ListGroup.list 'scroll_panel', 'play'
-      @play_count = play_list.count(@operators, 
-        {:id => @item.id, :my_play => @item.own?(@operators)}
+      @play_list = Locmare::ListGroup.list(
+        'scroll_panels', 'by_scroll', @operators, 
+        {:id => @item.id, :page_size => -1}  # set no limit options}
       )
     }
   end
@@ -45,32 +41,19 @@ class ScrollsController < ApplicationController
   end
   
   def play
-    @item = self.class.model.show(params[:id], @operators)
     set_play
     play_list
     respond_to do |format|
       format.html {
         if @item.own? @operators
-          @fresh_panel_items = assist_items('panel', 'public')
-          @new_panel_items = assist_items('panel', 'private')
+          @fresh_panel_items = assist_items('panels', 'index')
+          @new_panel_items = assist_items('home', 'panels')
         end
       }
-      format.json { render json: @items.to_json }
+      list_json_format @list, format
     end
   end
   
-  def count
-    list_count
-  end
-  
-  def count_by_author
-    list_count
-  end
-  
-  def count_by_panel
-    list_count
-  end
-  
   def new
     form_new
   end
@@ -96,17 +79,8 @@ class ScrollsController < ApplicationController
   end
   
   def destroy
-    @item = Scroll.edit(params[:id], @operators)
-    respond_to do |format|
-      if @item.destroy_with_leafs
-        flash[:notice] = I18n.t('flash.notice.destroyed', :model => Scroll.model_name.human)
-        format.html { redirect_to '/home/scrolls' }
-        format.json { head :ok }
-      else
-        flash[:notice] = I18n.t('flash.notice.not_destroyed', :model => Scroll.model_name.human)
-        format.html { redirect_to @item }
-        format.json { render json: @item.errors, status: :unprocessable_entity }
-      end
-    end
+    set_model
+    @item = @my_model_class.edit(params[:id], @operators)
+    render_destroy '/home/' + @item.path_name
   end
 end