OSDN Git Service

t#32025:comic rename
[pettanr/pettanr.git] / app / controllers / panels_controller.rb
index f099e64..8f55827 100644 (file)
@@ -1,12 +1,12 @@
 class PanelsController < ApplicationController
   layout 'test' if MagicNumber['test_layout']
   if MagicNumber['run_mode'] == 0
-    before_filter :authenticate_user, :only => [:new, :edit, :create, :update, :destroy]
-    before_filter :authenticate_author, :only => [:new, :edit, :create, :update, :destroy]
+    before_filter :authenticate_user, :only => [:new, :edit, :create, :update, :destroy, :catch]
+    before_filter :authenticate_author, :only => [:new, :edit, :create, :update, :destroy, :catch]
   else
     before_filter :authenticate_reader, :only => [:index, :show]
-    before_filter :authenticate_user, :only => [:new, :edit, :create, :update, :destroy]
-    before_filter :authenticate_author, :only => [:new, :edit, :create, :update, :destroy]
+    before_filter :authenticate_user, :only => [:new, :edit, :create, :update, :destroy, :catch]
+    before_filter :authenticate_author, :only => [:new, :edit, :create, :update, :destroy, :catch]
   end
   before_filter :authenticate_admin!, :only => [:list, :browse]
 
@@ -18,7 +18,9 @@ class PanelsController < ApplicationController
     @panels = Panel.list(@page, @page_size)
 
     respond_to do |format|
-      format.html # index.html.erb
+      format.html {
+        @paginate = Panel.list_paginate(@page, @page_size)
+      }
       format.json { render text: Panel.list_as_json_text(@panels) }
       format.atom 
       format.rss { render :layout => false }
@@ -31,8 +33,8 @@ class PanelsController < ApplicationController
     respond_to do |format|
       format.html {
         if @author
-          @new_comics = Comic.mylist(@author, 0, 5)
-          @fresh_comics = Story.mylist(@author, 0, 5).map {|s| s.comic}
+          @new_scrolls = Scroll.mylist(@author, 1, 5)
+          @fresh_scrolls = ScrollPanel.mylist(@author, 1, 5).map {|sp| sp.scroll}
         end
       }
       format.json { render json: @panel.panel_elements_as_json }
@@ -71,7 +73,7 @@ class PanelsController < ApplicationController
     @panel.supply_default
 
     respond_to do |format|
-      format.html { render layout: 'metro' }
+      format.html
       format.js
       format.json { render json: @panel.panel_elements_as_json }
     end
@@ -130,7 +132,7 @@ class PanelsController < ApplicationController
       Panel.transaction do
         if @panel.destroy_with_elements
           flash[:notice] = I18n.t('flash.notice.destroyed', :model => Panel.model_name.human)
-          format.html { redirect_to '/home/panel' }
+          format.html { redirect_to '/home/panels' }
           format.json { head :ok }
         else
           flash[:notice] = I18n.t('flash.notice.not_destroyed', :model => Panel.model_name.human)
@@ -141,4 +143,16 @@ class PanelsController < ApplicationController
     end
   end
   
+  def catch
+    @panel = Panel.edit(params[:id], @author)
+
+    respond_to do |format|
+      @author.working_panel_id = @panel.id
+      if @author.save
+        format.html { redirect_to @panel }
+      else
+      end
+    end
+  end
+
 end