]> source.dussan.org Git - redmine.git/commitdiff
Refactor: extract error to new method with before_filter.
authorEric Davis <edavis@littlestreamsoftware.com>
Mon, 26 Apr 2010 15:08:06 +0000 (15:08 +0000)
committerEric Davis <edavis@littlestreamsoftware.com>
Mon, 26 Apr 2010 15:08:06 +0000 (15:08 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3690 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/controllers/issues_controller.rb

index f30c83aa6f869567bf69387bef2abfa0b38ab4fb..6176a9cdb0d603aa7704865e6a1311a35aba5ee3 100644 (file)
@@ -24,6 +24,7 @@ class IssuesController < ApplicationController
   before_filter :find_project, :only => [:new, :create, :update_form, :preview, :auto_complete]
   before_filter :authorize, :except => [:index, :changes, :gantt, :calendar, :preview, :context_menu]
   before_filter :find_optional_project, :only => [:index, :changes, :gantt, :calendar]
+  before_filter :check_for_default_issue_status, :only => [:new, :create]
   before_filter :build_new_issue_from_params, :only => [:new, :create]
   accept_key_auth :index, :show, :changes
 
@@ -557,10 +558,6 @@ private
       render_error l(:error_no_tracker_in_project)
       return false
     end
-    if @issue.status.nil?
-      render_error l(:error_no_default_issue_status)
-      return false
-    end
     if params[:issue].is_a?(Hash)
       @issue.safe_attributes = params[:issue]
       @issue.watcher_user_ids = params[:issue]['watcher_user_ids'] if User.current.allowed_to?(:add_issue_watchers, @project)
@@ -581,4 +578,11 @@ private
                         :ids => '#' + unsaved_issue_ids.join(', #'))
     end
   end
+
+  def check_for_default_issue_status
+    if IssueStatus.default.nil?
+      render_error l(:error_no_default_issue_status)
+      return false
+    end
+  end
 end