Refactor: pull up method to ApplicationController.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3940 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Eric Davis 2010-08-13 14:59:04 +00:00
parent 32f6fa5b00
commit 13fe01a185
3 changed files with 15 additions and 23 deletions

View File

@ -365,6 +365,21 @@ class ApplicationController < ActionController::Base
flash[:warning] = l(:warning_attachments_not_saved, obj.unsaved_attachments.size) if obj.unsaved_attachments.present? flash[:warning] = l(:warning_attachments_not_saved, obj.unsaved_attachments.size) if obj.unsaved_attachments.present?
end end
# Sets the `flash` notice or error based the number of issues that did not save
#
# @param [Array, Issue] issues all of the saved and unsaved Issues
# @param [Array, Integer] unsaved_issue_ids the issue ids that were not saved
def set_flash_from_bulk_issue_save(issues, unsaved_issue_ids)
if unsaved_issue_ids.empty?
flash[:notice] = l(:notice_successful_update) unless issues.empty?
else
flash[:error] = l(:notice_failed_to_save_issues,
:count => unsaved_issue_ids.size,
:total => issues.size,
:ids => '#' + unsaved_issue_ids.join(', #'))
end
end
# Rescues an invalid query statement. Just in case... # Rescues an invalid query statement. Just in case...
def query_statement_invalid(exception) def query_statement_invalid(exception)
logger.error "Query::StatementInvalid: #{exception.message}" if logger logger.error "Query::StatementInvalid: #{exception.message}" if logger

View File

@ -52,18 +52,6 @@ class IssueMovesController < ApplicationController
@available_statuses = Workflow.available_statuses(@project) @available_statuses = Workflow.available_statuses(@project)
end end
# TODO: duplicated in IssuesController
def set_flash_from_bulk_issue_save(issues, unsaved_issue_ids)
if unsaved_issue_ids.empty?
flash[:notice] = l(:notice_successful_update) unless issues.empty?
else
flash[:error] = l(:notice_failed_to_save_issues,
:count => unsaved_issue_ids.size,
:total => issues.size,
:ids => '#' + unsaved_issue_ids.join(', #'))
end
end
def extract_changed_attributes_for_move(params) def extract_changed_attributes_for_move(params)
changed_attributes = {} changed_attributes = {}
[:assigned_to_id, :status_id, :start_date, :due_date].each do |valid_attribute| [:assigned_to_id, :status_id, :start_date, :due_date].each do |valid_attribute|

View File

@ -408,17 +408,6 @@ private
@allowed_statuses = @issue.new_statuses_allowed_to(User.current, true) @allowed_statuses = @issue.new_statuses_allowed_to(User.current, true)
end end
def set_flash_from_bulk_issue_save(issues, unsaved_issue_ids)
if unsaved_issue_ids.empty?
flash[:notice] = l(:notice_successful_update) unless issues.empty?
else
flash[:error] = l(:notice_failed_to_save_issues,
:count => unsaved_issue_ids.size,
:total => issues.size,
:ids => '#' + unsaved_issue_ids.join(', #'))
end
end
def check_for_default_issue_status def check_for_default_issue_status
if IssueStatus.default.nil? if IssueStatus.default.nil?
render_error l(:error_no_default_issue_status) render_error l(:error_no_default_issue_status)