summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean-Baptiste Barth <jeanbaptiste.barth@gmail.com>2010-09-29 05:22:53 +0000
committerJean-Baptiste Barth <jeanbaptiste.barth@gmail.com>2010-09-29 05:22:53 +0000
commit4853dd97fd5a39eec56155baba8844adcefa9aa4 (patch)
tree156b7a284907f850589e83f1bc952512e874152e
parente8f3dd07dd8462d8d80948d5c8f094bdcc966d9a (diff)
downloadredmine-4853dd97fd5a39eec56155baba8844adcefa9aa4.tar.gz
redmine-4853dd97fd5a39eec56155baba8844adcefa9aa4.zip
Splitted #find_issues filter in ApplicationController to #find_issues and #check_project_uniqueness (#5332)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4228 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r--app/controllers/application_controller.rb15
-rw-r--r--app/controllers/issue_moves_controller.rb2
-rw-r--r--app/controllers/issues_controller.rb1
3 files changed, 11 insertions, 7 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 32bb528a3..fd6fc52da 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -213,16 +213,19 @@ class ApplicationController < ActionController::Base
def find_issues
@issues = Issue.find_all_by_id(params[:id] || params[:ids])
raise ActiveRecord::RecordNotFound if @issues.empty?
- projects = @issues.collect(&:project).compact.uniq
- if projects.size == 1
- @project = projects.first
- else
+ @projects = @issues.collect(&:project).compact.uniq
+ @project = @projects.first if @projects.size == 1
+ rescue ActiveRecord::RecordNotFound
+ render_404
+ end
+
+ # Check if project is unique before bulk operations
+ def check_project_uniqueness
+ unless @project
# TODO: let users bulk edit/move/destroy issues from different projects
render_error 'Can not bulk edit/move/destroy issues from different projects'
return false
end
- rescue ActiveRecord::RecordNotFound
- render_404
end
# make sure that the user is a member of the project (or admin) if project is private
diff --git a/app/controllers/issue_moves_controller.rb b/app/controllers/issue_moves_controller.rb
index 6ac46a1ee..20da38755 100644
--- a/app/controllers/issue_moves_controller.rb
+++ b/app/controllers/issue_moves_controller.rb
@@ -1,6 +1,6 @@
class IssueMovesController < ApplicationController
default_search_scope :issues
- before_filter :find_issues
+ before_filter :find_issues, :check_project_uniqueness
before_filter :authorize
def new
diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb
index a48a9e8ff..d1378777a 100644
--- a/app/controllers/issues_controller.rb
+++ b/app/controllers/issues_controller.rb
@@ -21,6 +21,7 @@ class IssuesController < ApplicationController
before_filter :find_issue, :only => [:show, :edit, :update]
before_filter :find_issues, :only => [:bulk_edit, :bulk_update, :move, :perform_move, :destroy]
+ before_filter :check_project_uniqueness, :only => [:bulk_edit, :bulk_update, :move, :perform_move, :destroy]
before_filter :find_project, :only => [:new, :create]
before_filter :authorize, :except => [:index]
before_filter :find_optional_project, :only => [:index]