Skip to content

Commit

Permalink
Refactor: extract error to new method with before_filter.
Browse files Browse the repository at this point in the history
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3690 e93f8b46-1217-0410-a6f0-8f06a7374b81
  • Loading branch information
edavis10 committed Apr 26, 2010
1 parent 23f097e commit dfc4480
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions app/controllers/issues_controller.rb
Expand Up @@ -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

Expand Down Expand Up @@ -557,10 +558,6 @@ def build_new_issue_from_params
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)
Expand All @@ -581,4 +578,11 @@ def set_flash_from_bulk_issue_save(issues, unsaved_issue_ids)
: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

0 comments on commit dfc4480

Please sign in to comment.