OSDN Git Service

t#32046:
[pettanr/pettanr.git] / app / controllers / scroll_panels_controller.rb
index 5e0b739..f694433 100644 (file)
@@ -32,39 +32,6 @@ class ScrollPanelsController < ApplicationController
     end
   end
   
-  def scroll
-    @scroll = Scroll.show(params[:id], [@user, @admin])
-    cnt = ScrollPanel.count(:conditions => ['scroll_id = ?', @scroll.id]).to_i
-    @offset = ScrollPanel.offset cnt, params[:offset]
-    @panel_count = ScrollPanel.panel_count cnt, params[:count]
-    @scroll_panels = ScrollPanel.play_list(@scroll, @author, @offset, @panel_count)
-    respond_to do |format|
-      format.html {
-        @prev_offset = if @offset > 0
-          if @offset - @panel_count < 0
-            0
-          else
-            @offset - @panel_count
-          end
-        else
-          nil
-        end
-        @next_offset = if @offset + @panel_count > cnt
-          nil
-        else
-          @offset + @panel_count
-        end
-        if @author
-          @new_panels = Panel.mylist(@author, 1, 5)
-        end
-      }
-      format.json {render text: ScrollPanel.list_as_json_text(@scroll_panels, @author)}
-      format.jsonp {
-        render :json => "callback(" + @scroll_panels.to_json_list + ");"
-      }
-    end
-  end
-  
   def list
     @scroll_panels = ScrollPanel.all
 
@@ -112,7 +79,7 @@ class ScrollPanelsController < ApplicationController
     respond_to do |format|
       if @scroll_panel.store
         flash[:notice] = I18n.t('flash.notice.created', :model => ScrollPanel.model_name.human)
-        format.html { redirect_to action: :scroll, id: @scroll_panel.scroll_id }
+        format.html { redirect_to play_scroll_path(@scroll) }
         format.json { render json: @scroll_panel.scroll_panel_as_json(@author) }
       else
         flash[:notice] = I18n.t('flash.notice.not_created', :model => ScrollPanel.model_name.human)
@@ -127,10 +94,11 @@ class ScrollPanelsController < ApplicationController
     ot = @scroll_panel.t
     @scroll_panel.attributes = params[:scroll_panel]
     @scroll_panel.overwrite @author
+    @scroll = Scroll.edit(@scroll_panel.scroll_id, @author) if @scroll_panel.scroll_id
     respond_to do |format|
       if @scroll_panel.store ot
         flash[:notice] = I18n.t('flash.notice.updated', :model => ScrollPanel.model_name.human)
-        format.html { redirect_to action: :scroll, id: @scroll_panel.scroll_id }
+        format.html { redirect_to play_scroll_path(@scroll) }
         format.json { head :ok }
       else
         flash[:notice] = I18n.t('flash.notice.not_updated', :model => ScrollPanel.model_name.human)
@@ -142,10 +110,11 @@ class ScrollPanelsController < ApplicationController
 
   def destroy
     @scroll_panel = ScrollPanel.edit(params[:id], @author)
+    @scroll = Scroll.edit(@scroll_panel.scroll_id, @author) if @scroll_panel.scroll_id
     respond_to do |format|
       if @scroll_panel.destroy_and_shorten
         flash[:notice] = I18n.t('flash.notice.destroyed', :model => ScrollPanel.model_name.human)
-        format.html { redirect_to :controller => 'scroll_panels', :action => :scroll, :id => @scroll_panel.scroll_id }
+        format.html { redirect_to play_scroll_path(@scroll) }
         format.json { head :ok }
       else
         flash[:notice] = I18n.t('flash.notice.not_destroyed', :model => ScrollPanel.model_name.human)