Skip to content

Commit

Permalink
Splitted #find_issues filter in ApplicationController to #find_issues…
Browse files Browse the repository at this point in the history
… and #check_project_uniqueness (#5332)

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4228 e93f8b46-1217-0410-a6f0-8f06a7374b81
  • Loading branch information
jbbarth committed Sep 29, 2010
1 parent e8f3dd0 commit 4853dd9
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
15 changes: 9 additions & 6 deletions app/controllers/application_controller.rb
Expand Up @@ -213,16 +213,19 @@ def self.model_object(model)
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
Expand Down
2 changes: 1 addition & 1 deletion 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
Expand Down
1 change: 1 addition & 0 deletions app/controllers/issues_controller.rb
Expand Up @@ -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]
Expand Down

0 comments on commit 4853dd9

Please sign in to comment.