OSDN Git Service

t#32326:fix work
authoryasushiito <yas@pen-chan.jp>
Sat, 26 Oct 2013 00:01:43 +0000 (09:01 +0900)
committeryasushiito <yas@pen-chan.jp>
Sat, 26 Oct 2013 00:01:43 +0000 (09:01 +0900)
app/controllers/application_controller.rb
app/controllers/ground_colors_controller.rb
app/controllers/ground_pictures_controller.rb
app/controllers/panel_pictures_controller.rb
app/controllers/speech_balloons_controller.rb
config/application.rb
public/not_work.html [new file with mode: 0644]

index 0f3fade..5c5b63a 100644 (file)
@@ -136,6 +136,21 @@ class ApplicationController < ActionController::Base
     export_from_provider(url)
   end
   
+    rescue_from Pettanr::NotWork, :with => :render_not_work
+    def render_not_work(exception = nil)
+      if exception
+        logger.info "Rendering , :: #{exception.message}"
+      end
+      respond_to do |format|
+        format.html { 
+          render :file => "#{Rails.root}/public/not_work.html", :layout => false
+        }
+        format.json { 
+          render :text => "400 Not work", :status => 400
+        }
+      end
+    end
+    
   if Rails.env == 'production'
     rescue_from ActiveRecord::RecordNotFound, :with => :render_404
     rescue_from ActiveRecord::Forbidden, :with => :render_403
index 139699c..e9456f9 100644 (file)
@@ -31,6 +31,7 @@ class GroundColorsController < ApplicationController
   end
   
   def new
+    raise Pettanr::NotWork unless @author.working_panel
     @panel = Panel.edit(@author.working_panel, @author)
     @ground_color = GroundColor.new :panel_id => @panel.id, :code => params[:code].to_i
     @ground_color.supply_default
@@ -51,6 +52,7 @@ class GroundColorsController < ApplicationController
   end
 
   def create
+    raise Pettanr::NotWork unless @author.working_panel
     @panel = Panel.edit(@author.working_panel, @author)
     
     @ground_color = GroundColor.new 
index 26c14b7..9cf4159 100644 (file)
@@ -31,6 +31,7 @@ class GroundPicturesController < ApplicationController
   end
   
   def new
+    raise Pettanr::NotWork unless @author.working_panel
     @picture = Picture.show params[:picture_id], @author
     raise ActiveRecord::Forbidden unless @picture.enable?
     @panel = Panel.edit(@author.working_panel, @author)
@@ -54,6 +55,7 @@ class GroundPicturesController < ApplicationController
   end
 
   def create
+    raise Pettanr::NotWork unless @author.working_panel
     @panel = Panel.edit(@author.working_panel, @author)
     
     @ground_picture = GroundPicture.new
index f093949..5a98947 100644 (file)
@@ -51,6 +51,7 @@ class PanelPicturesController < ApplicationController
   end
 
   def new
+    raise Pettanr::NotWork unless @author.working_panel
     @picture = Picture.show params[:picture_id], @author
     raise ActiveRecord::Forbidden unless @picture.enable?
     @panel = Panel.edit(@author.working_panel, @author)
@@ -74,6 +75,7 @@ class PanelPicturesController < ApplicationController
   end
 
   def create
+    raise Pettanr::NotWork unless @author.working_panel
     @panel = Panel.edit(@author.working_panel, @author)
     
     @panel_picture = PanelPicture.new 
index 03be3ac..bc5aea8 100644 (file)
@@ -50,6 +50,7 @@ class SpeechBalloonsController < ApplicationController
   end
 
   def new
+    raise Pettanr::NotWork unless @author.working_panel
     @speech_balloon_template = SpeechBalloonTemplate.show params[:speech_balloon_template_id], @author
     
     @panel = Panel.edit(@author.working_panel, @author)
@@ -82,6 +83,7 @@ class SpeechBalloonsController < ApplicationController
   end
 
   def create
+    raise Pettanr::NotWork unless @author.working_panel
     SpeechBalloon.fold_extend_settings params
     @panel = Panel.edit(@author.working_panel, @author)
     @speech_balloon = SpeechBalloon.new 
index 3e62c61..8a2e303 100644 (file)
@@ -119,5 +119,7 @@ module Pettanr
   TestLayout = false
   class BadRequest < StandardError
   end
+  class NotWork < StandardError
+  end
 end
 
diff --git a/public/not_work.html b/public/not_work.html
new file mode 100644 (file)
index 0000000..5f8b3bd
--- /dev/null
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <title>コマをつかんでいません</title>
+  <style type="text/css">
+    body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
+    div.dialog {
+      width: 25em;
+      padding: 0 4em;
+      margin: 4em auto 0 auto;
+      border: 1px solid #ccc;
+      border-right-color: #999;
+      border-bottom-color: #999;
+    }
+    h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
+  </style>
+</head>
+
+<body>
+  <!-- This file lives in public/404.html -->
+  <div class="dialog">
+    <h1>作業対象のコマが指定されていません。</h1>
+    <p>エレメントを新規作成するなど、一部の操作ではコマをつかんでおく必要があります。</p>
+  </div>
+</body>
+</html>