OSDN Git Service

fix form extend
[pettanr/pettanr.git] / app / controllers / speech_balloons_controller.rb
index 4aede9d..a1551f2 100644 (file)
@@ -1,10 +1,11 @@
 class SpeechBalloonsController < ApplicationController
-  layout 'test' if MagicNumber['test_layout']
-  if MagicNumber['run_mode'] == 0
+  if Manifest.manifest.magic_numbers['run_mode'] == 0
     before_filter :authenticate_user, :only => [:new, :edit, :create, :update, :destroy]
     before_filter :authenticate_author, :only => [:new, :edit, :create, :update, :destroy]
   else
-    before_filter :authenticate_reader, :only => [:index, :show, :by_panel, :by_author]
+    before_filter :authenticate_reader, :only => [
+      :index, :show, :by_panel, :by_author, :count, :count_by_panel, :count_by_author
+    ]
     before_filter :authenticate_user, :only => [:new, :edit, :create, :update, :destroy]
     before_filter :authenticate_author, :only => [:new, :edit, :create, :update, :destroy]
   end
@@ -14,61 +15,52 @@ class SpeechBalloonsController < ApplicationController
   end
   
   def index
-    public_list
+    filer_list
   end
   
   def by_panel
-    filter_list
+    filer_list
   end
   
   def by_author
-    filter_list
+    filer_list
+  end
+  
+  def show_html_format format
+    format.html {
+      @speech_balloon = @item
+    }
   end
   
   def show
-    @item = SpeechBalloon.show(params[:id], @operators)
+    set_show
     respond_to do |format|
-      format.html {
-        @speech_balloon = @item
-      }
-      format_prof format
-      format.json { render json: @item.to_json(SpeechBalloon.show_json_opt) }
+      show_html_format format
+      show_prof_format format
+      show_json_format format
     end
   end
   
+  def count
+    list_count
+  end
+  
+  def count_by_panel
+    list_count
+  end
+  
+  def count_by_author
+    list_count
+  end
+  
   def new
-    raise Pettanr::NotWork unless @operators.author.working_panel
-    @speech_balloon_template = SpeechBalloonTemplate.show params[:speech_balloon_template_id], @operators
-    
-    @panel = Panel.edit(@operators.author.working_panel, @operators)
-    @speech_balloon = SpeechBalloon.new :panel_id => @panel.id, :speech_balloon_template_id => @speech_balloon_template.id
-    @speech_balloon.boost
-    @speech_balloon.supply_default
-    @speech_balloon.get_balloon.supply_default 
-    @speech_balloon.get_speech.supply_default 
-    
-    respond_to do |format|
-      format.html {
-        render @speech_balloon_template.engine_name + '/speech_balloons/new'
-      }
-      format.json { render :json => @speech_balloon.to_json(SpeechBalloon.show_json_opt) }
-    end
+    form_new
   end
-
+  
   def edit
-    @speech_balloon = SpeechBalloon.show(params[:id], @operators)
-    @speech_balloon_template = @speech_balloon.speech_balloon_template
-    @panel = Panel.edit(@speech_balloon.panel.id,@operators)
-    
-    @speech_balloon.boost
-    
-    respond_to do |format|
-      format.html {
-        render @speech_balloon_template.engine_name + '/speech_balloons/edit'
-      }
-    end
+    form_edit
   end
-
+  
   def create
     raise Pettanr::NotWork unless @operators.author.working_panel
     SpeechBalloon.fold_extend_settings params