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:
parent
2ecca7e4df
commit
b255b7760a
|
@ -153,7 +153,7 @@ class ApplicationController < ActionController::Base
|
||||||
|
|
||||||
# Authorize the user for the requested action
|
# Authorize the user for the requested action
|
||||||
def authorize(ctrl = params[:controller], action = params[:action], global = false)
|
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
|
allowed ? true : deny_access
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -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?))),
|
: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)),
|
:move => (@project && User.current.allowed_to?(:move_issues, @project)),
|
||||||
:copy => (@issue && @project.trackers.include?(@issue.tracker) && User.current.allowed_to?(:add_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
|
if @project
|
||||||
@assignables = @project.assignable_users
|
@assignables = @project.assignable_users
|
||||||
|
|
|
@ -21,7 +21,7 @@ class IssuesController < ApplicationController
|
||||||
|
|
||||||
before_filter :find_issue, :only => [:show, :edit, :update]
|
before_filter :find_issue, :only => [:show, :edit, :update]
|
||||||
before_filter :find_issues, :only => [:bulk_edit, :bulk_update, :move, :perform_move, :destroy]
|
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 :find_project, :only => [:new, :create]
|
||||||
before_filter :authorize, :except => [:index]
|
before_filter :authorize, :except => [:index]
|
||||||
before_filter :find_optional_project, :only => [:index]
|
before_filter :find_optional_project, :only => [:index]
|
||||||
|
@ -242,7 +242,7 @@ class IssuesController < ApplicationController
|
||||||
end
|
end
|
||||||
@issues.each(&:destroy)
|
@issues.each(&:destroy)
|
||||||
respond_to do |format|
|
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.xml { head :ok }
|
||||||
format.json { head :ok }
|
format.json { head :ok }
|
||||||
end
|
end
|
||||||
|
|
|
@ -115,7 +115,7 @@
|
||||||
:class => 'icon-copy', :disabled => !@can[:move] %></li>
|
:class => 'icon-copy', :disabled => !@can[:move] %></li>
|
||||||
<li><%= context_menu_link l(:button_move), new_issue_move_path(:ids => @issues.collect(&:id)),
|
<li><%= context_menu_link l(:button_move), new_issue_move_path(:ids => @issues.collect(&:id)),
|
||||||
:class => 'icon-move', :disabled => !@can[:move] %></li>
|
: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>
|
: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 }) %>
|
<%= call_hook(:view_issues_context_menu_end, {:issues => @issues, :can => @can, :back => @back }) %>
|
||||||
|
|
|
@ -79,14 +79,15 @@ class ContextMenusControllerTest < ActionController::TestCase
|
||||||
:class => 'icon-del' }
|
:class => 'icon-del' }
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_context_menu_multiple_issues_of_different_project
|
def test_context_menu_multiple_issues_of_different_projects
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
get :issues, :ids => [1, 2, 4]
|
get :issues, :ids => [1, 2, 6]
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_template 'context_menu'
|
assert_template 'context_menu'
|
||||||
|
ids = "ids%5B%5D=1&ids%5B%5D=2&ids%5B%5D=6"
|
||||||
assert_tag :tag => 'a', :content => 'Delete',
|
assert_tag :tag => 'a', :content => 'Delete',
|
||||||
:attributes => { :href => '#',
|
:attributes => { :href => "/issues/destroy?#{ids}",
|
||||||
:class => 'icon-del disabled' }
|
:class => 'icon-del' }
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -1061,6 +1061,13 @@ class IssuesControllerTest < ActionController::TestCase
|
||||||
assert_equal 2, TimeEntry.find(2).issue_id
|
assert_equal 2, TimeEntry.find(2).issue_id
|
||||||
end
|
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
|
def test_default_search_scope
|
||||||
get :index
|
get :index
|
||||||
assert_tag :div, :attributes => {:id => 'quick-search'},
|
assert_tag :div, :attributes => {:id => 'quick-search'},
|
||||||
|
|
Loading…
Reference in New Issue