From 9f5258607f0be5c8c6f4f8f9efb85ec462f33b68 Mon Sep 17 00:00:00 2001 From: yasushiito Date: Sat, 26 Oct 2013 09:01:43 +0900 Subject: [PATCH] t#32326:fix work --- app/controllers/application_controller.rb | 15 +++++++++++++++ app/controllers/ground_colors_controller.rb | 2 ++ app/controllers/ground_pictures_controller.rb | 2 ++ app/controllers/panel_pictures_controller.rb | 2 ++ app/controllers/speech_balloons_controller.rb | 2 ++ config/application.rb | 2 ++ public/not_work.html | 26 ++++++++++++++++++++++++++ 7 files changed, 51 insertions(+) create mode 100644 public/not_work.html diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 0f3fadef..5c5b63a6 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -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 diff --git a/app/controllers/ground_colors_controller.rb b/app/controllers/ground_colors_controller.rb index 139699c3..e9456f90 100644 --- a/app/controllers/ground_colors_controller.rb +++ b/app/controllers/ground_colors_controller.rb @@ -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 diff --git a/app/controllers/ground_pictures_controller.rb b/app/controllers/ground_pictures_controller.rb index 26c14b77..9cf4159f 100644 --- a/app/controllers/ground_pictures_controller.rb +++ b/app/controllers/ground_pictures_controller.rb @@ -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 diff --git a/app/controllers/panel_pictures_controller.rb b/app/controllers/panel_pictures_controller.rb index f0939491..5a98947d 100644 --- a/app/controllers/panel_pictures_controller.rb +++ b/app/controllers/panel_pictures_controller.rb @@ -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 diff --git a/app/controllers/speech_balloons_controller.rb b/app/controllers/speech_balloons_controller.rb index 03be3ac9..bc5aea82 100644 --- a/app/controllers/speech_balloons_controller.rb +++ b/app/controllers/speech_balloons_controller.rb @@ -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 diff --git a/config/application.rb b/config/application.rb index 3e62c613..8a2e3032 100644 --- a/config/application.rb +++ b/config/application.rb @@ -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 index 00000000..5f8b3bd2 --- /dev/null +++ b/public/not_work.html @@ -0,0 +1,26 @@ + + + + コマをつかんでいません + + + + + +
+

作業対象のコマが指定されていません。

+

エレメントを新規作成するなど、一部の操作ではコマをつかんでおく必要があります。

+
+ + -- 2.11.0