OSDN Git Service

work
[pettanr/pettanr.git] / app / controllers / speech_balloons_controller.rb
index 8bfe140..6e95295 100644 (file)
@@ -10,30 +10,22 @@ class SpeechBalloonsController < ApplicationController
   end
   before_filter :authenticate_admin!, :only => [:list, :browse]
 
+  def self.model
+    SpeechBalloon
+  end
+  
   def index
-    @page = SpeechBalloon.page params[:page]
-    @page_size = SpeechBalloon.page_size params[:page_size]
-    @speech_balloons = SpeechBalloon.list(@page, @page_size)
-
-    respond_to do |format|
-      format.html {
-        @paginate = SpeechBalloon.list_paginate(@page, @page_size)
-        render :template => 'system/filer', :locals => {
-          :items => @speech_balloons, :model => SpeechBalloon, 
-          :roles => [@user, @admin], :pager => @paginate
-        }
-      }
-      format.json { render json: @speech_balloons.to_json(SpeechBalloon.list_json_opt) }
-    end
+    public_list
   end
   
   def show
-    @speech_balloon = SpeechBalloon.show(params[:id], [@user, @admin])
+    @item = SpeechBalloon.show(params[:id], @operators)
     respond_to do |format|
-      format.html # show.html.erb
-      format.prof  { render :template => 'top/prof', :layout => true }
-      format.prof  { render :template => 'top/prof', :layout => true }
-      format.json { render json: @speech_balloon.to_json(SpeechBalloon.show_json_opt) }
+      format.html {
+        @speech_balloon = @item
+      }
+      format_prof format
+      format.json { render json: @item.to_json(SpeechBalloon.show_json_opt) }
     end
   end
   
@@ -56,10 +48,10 @@ class SpeechBalloonsController < ApplicationController
   end
 
   def new
-    raise Pettanr::NotWork unless @author.working_panel
-    @speech_balloon_template = SpeechBalloonTemplate.show params[:speech_balloon_template_id], @author
+    raise Pettanr::NotWork unless @operators.author.working_panel
+    @speech_balloon_template = SpeechBalloonTemplate.show params[:speech_balloon_template_id], @operators
     
-    @panel = Panel.edit(@author.working_panel, @author)
+    @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
@@ -75,9 +67,9 @@ class SpeechBalloonsController < ApplicationController
   end
 
   def edit
-    @speech_balloon = SpeechBalloon.show(params[:id], @author)
+    @speech_balloon = SpeechBalloon.show(params[:id], @operators.author)
     @speech_balloon_template = @speech_balloon.speech_balloon_template
-    @panel = Panel.edit(@speech_balloon.panel.id, @author)
+    @panel = Panel.edit(@speech_balloon.panel.id, @operators.author)
     
     @speech_balloon.boost
     
@@ -89,9 +81,9 @@ class SpeechBalloonsController < ApplicationController
   end
 
   def create
-    raise Pettanr::NotWork unless @author.working_panel
+    raise Pettanr::NotWork unless @operators.author.working_panel
     SpeechBalloon.fold_extend_settings params
-    @panel = Panel.edit(@author.working_panel, @author)
+    @panel = Panel.edit(@operators.author.working_panel, @author)
     @speech_balloon = SpeechBalloon.new 
     @speech_balloon.attributes = params[:speech_balloon]
     
@@ -119,7 +111,7 @@ class SpeechBalloonsController < ApplicationController
 
   def update
     SpeechBalloon.fold_extend_settings params
-    @speech_balloon = SpeechBalloon.show(params[:id], @author)
+    @speech_balloon = SpeechBalloon.show(params[:id], @operators.author)
     @speech_balloon.attributes = params[:speech_balloon]
     
     @speech_balloon_template = @speech_balloon.speech_balloon_template
@@ -127,11 +119,11 @@ class SpeechBalloonsController < ApplicationController
     
     params[:speech_balloon][:balloon_attributes][:system_picture_id] = @speech_balloon.get_balloon.select_system_picture 
     
-    @panel = Panel.edit(@speech_balloon.panel.id, @author)
+    @panel = Panel.edit(@speech_balloon.panel.id, @operators.author)
     @speech_balloon.overwrite @panel.id
     
     respond_to do |format|
-      if @speech_balloon.valid? and @speech_balloon.store(@author, params[:speech_balloon])
+      if @speech_balloon.valid? and @speech_balloon.store(@operators.author, params[:speech_balloon])
         flash[:notice] = I18n.t('flash.notice.updated', :model => SpeechBalloon.model_name.human)
         format.html { redirect_to @speech_balloon }
         format.json { head :ok }
@@ -146,11 +138,11 @@ class SpeechBalloonsController < ApplicationController
   end
 
   def destroy
-    @speech_balloon = SpeechBalloon.show(params[:id], @author)
-    @panel = Panel.edit(@speech_balloon.panel.id, @author)
+    @speech_balloon = SpeechBalloon.show(params[:id], @operators.author)
+    @panel = Panel.edit(@speech_balloon.panel.id, @operators.author)
     
     respond_to do |format|
-      if @speech_balloon.remove @author
+      if @speech_balloon.remove @operators.author
         flash[:notice] = I18n.t('flash.notice.destroyed', :model => SpeechBalloon.model_name.human)
         format.html { redirect_to @panel }
         format.json { head :ok }