Added ability to delete issues from different projects through contextual menu (#5332)

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4236 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Baptiste Barth 2010-10-07 05:11:28 +00:00
parent 2ecca7e4df
commit b255b7760a
6 changed files with 17 additions and 9 deletions

View File

@ -153,7 +153,7 @@ class ApplicationController < ActionController::Base
# Authorize the user for the requested action
def authorize(ctrl = params[:controller], action = params[:action], global = false)
allowed = User.current.allowed_to?({:controller => ctrl, :action => action}, @project, :global => global)
allowed = User.current.allowed_to?({:controller => ctrl, :action => action}, @project || @projects, :global => global)
allowed ? true : deny_access
end

View File

@ -21,7 +21,7 @@ class ContextMenusController < ApplicationController
:update => (@project && (User.current.allowed_to?(:edit_issues, @project) || (User.current.allowed_to?(:change_status, @project) && @allowed_statuses && !@allowed_statuses.empty?))),
:move => (@project && User.current.allowed_to?(:move_issues, @project)),
:copy => (@issue && @project.trackers.include?(@issue.tracker) && User.current.allowed_to?(:add_issues, @project)),
:delete => (@project && User.current.allowed_to?(:delete_issues, @project))
:delete => User.current.allowed_to?(:delete_issues, @projects)
}
if @project
@assignables = @project.assignable_users

View File

@ -21,7 +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 :check_project_uniqueness, :only => [:bulk_edit, :bulk_update, :move, :perform_move]
before_filter :find_project, :only => [:new, :create]
before_filter :authorize, :except => [:index]
before_filter :find_optional_project, :only => [:index]
@ -242,7 +242,7 @@ class IssuesController < ApplicationController
end
@issues.each(&:destroy)
respond_to do |format|
format.html { redirect_to :action => 'index', :project_id => @project }
format.html { redirect_back_or_default(:action => 'index', :project_id => @project) }
format.xml { head :ok }
format.json { head :ok }
end

View File

@ -115,7 +115,7 @@
:class => 'icon-copy', :disabled => !@can[:move] %></li>
<li><%= context_menu_link l(:button_move), new_issue_move_path(:ids => @issues.collect(&:id)),
:class => 'icon-move', :disabled => !@can[:move] %></li>
<li><%= context_menu_link l(:button_delete), {:controller => 'issues', :action => 'destroy', :ids => @issues.collect(&:id)},
<li><%= context_menu_link l(:button_delete), {:controller => 'issues', :action => 'destroy', :ids => @issues.collect(&:id), :back_url => @back},
:method => :post, :confirm => l(:text_issues_destroy_confirmation), :class => 'icon-del', :disabled => !@can[:delete] %></li>
<%= call_hook(:view_issues_context_menu_end, {:issues => @issues, :can => @can, :back => @back }) %>

View File

@ -79,14 +79,15 @@ class ContextMenusControllerTest < ActionController::TestCase
:class => 'icon-del' }
end
def test_context_menu_multiple_issues_of_different_project
def test_context_menu_multiple_issues_of_different_projects
@request.session[:user_id] = 2
get :issues, :ids => [1, 2, 4]
get :issues, :ids => [1, 2, 6]
assert_response :success
assert_template 'context_menu'
ids = "ids%5B%5D=1&amp;ids%5B%5D=2&amp;ids%5B%5D=6"
assert_tag :tag => 'a', :content => 'Delete',
:attributes => { :href => '#',
:class => 'icon-del disabled' }
:attributes => { :href => "/issues/destroy?#{ids}",
:class => 'icon-del' }
end
end

View File

@ -1061,6 +1061,13 @@ class IssuesControllerTest < ActionController::TestCase
assert_equal 2, TimeEntry.find(2).issue_id
end
def test_destroy_issues_from_different_projects
@request.session[:user_id] = 2
post :destroy, :ids => [1, 2, 6], :todo => 'destroy'
assert_redirected_to :controller => 'issues', :action => 'index'
assert !(Issue.find_by_id(1) || Issue.find_by_id(2) || Issue.find_by_id(6))
end
def test_default_search_scope
get :index
assert_tag :div, :attributes => {:id => 'quick-search'},