##// END OF EJS Templates
Added ability to delete issues from different projects through contextual menu (#5332)...
Jean-Baptiste Barth -
r4122:b255b7760ac6
parent child
Show More
@@ -153,7 +153,7 class ApplicationController < ActionController::Base
153
153
154 # Authorize the user for the requested action
154 # Authorize the user for the requested action
155 def authorize(ctrl = params[:controller], action = params[:action], global = false)
155 def authorize(ctrl = params[:controller], action = params[:action], global = false)
156 allowed = User.current.allowed_to?({:controller => ctrl, :action => action}, @project, :global => global)
156 allowed = User.current.allowed_to?({:controller => ctrl, :action => action}, @project || @projects, :global => global)
157 allowed ? true : deny_access
157 allowed ? true : deny_access
158 end
158 end
159
159
@@ -21,7 +21,7 class ContextMenusController < ApplicationController
21 :update => (@project && (User.current.allowed_to?(:edit_issues, @project) || (User.current.allowed_to?(:change_status, @project) && @allowed_statuses && !@allowed_statuses.empty?))),
21 :update => (@project && (User.current.allowed_to?(:edit_issues, @project) || (User.current.allowed_to?(:change_status, @project) && @allowed_statuses && !@allowed_statuses.empty?))),
22 :move => (@project && User.current.allowed_to?(:move_issues, @project)),
22 :move => (@project && User.current.allowed_to?(:move_issues, @project)),
23 :copy => (@issue && @project.trackers.include?(@issue.tracker) && User.current.allowed_to?(:add_issues, @project)),
23 :copy => (@issue && @project.trackers.include?(@issue.tracker) && User.current.allowed_to?(:add_issues, @project)),
24 :delete => (@project && User.current.allowed_to?(:delete_issues, @project))
24 :delete => User.current.allowed_to?(:delete_issues, @projects)
25 }
25 }
26 if @project
26 if @project
27 @assignables = @project.assignable_users
27 @assignables = @project.assignable_users
@@ -21,7 +21,7 class IssuesController < ApplicationController
21
21
22 before_filter :find_issue, :only => [:show, :edit, :update]
22 before_filter :find_issue, :only => [:show, :edit, :update]
23 before_filter :find_issues, :only => [:bulk_edit, :bulk_update, :move, :perform_move, :destroy]
23 before_filter :find_issues, :only => [:bulk_edit, :bulk_update, :move, :perform_move, :destroy]
24 before_filter :check_project_uniqueness, :only => [:bulk_edit, :bulk_update, :move, :perform_move, :destroy]
24 before_filter :check_project_uniqueness, :only => [:bulk_edit, :bulk_update, :move, :perform_move]
25 before_filter :find_project, :only => [:new, :create]
25 before_filter :find_project, :only => [:new, :create]
26 before_filter :authorize, :except => [:index]
26 before_filter :authorize, :except => [:index]
27 before_filter :find_optional_project, :only => [:index]
27 before_filter :find_optional_project, :only => [:index]
@@ -242,7 +242,7 class IssuesController < ApplicationController
242 end
242 end
243 @issues.each(&:destroy)
243 @issues.each(&:destroy)
244 respond_to do |format|
244 respond_to do |format|
245 format.html { redirect_to :action => 'index', :project_id => @project }
245 format.html { redirect_back_or_default(:action => 'index', :project_id => @project) }
246 format.xml { head :ok }
246 format.xml { head :ok }
247 format.json { head :ok }
247 format.json { head :ok }
248 end
248 end
@@ -115,7 +115,7
115 :class => 'icon-copy', :disabled => !@can[:move] %></li>
115 :class => 'icon-copy', :disabled => !@can[:move] %></li>
116 <li><%= context_menu_link l(:button_move), new_issue_move_path(:ids => @issues.collect(&:id)),
116 <li><%= context_menu_link l(:button_move), new_issue_move_path(:ids => @issues.collect(&:id)),
117 :class => 'icon-move', :disabled => !@can[:move] %></li>
117 :class => 'icon-move', :disabled => !@can[:move] %></li>
118 <li><%= context_menu_link l(:button_delete), {:controller => 'issues', :action => 'destroy', :ids => @issues.collect(&:id)},
118 <li><%= context_menu_link l(:button_delete), {:controller => 'issues', :action => 'destroy', :ids => @issues.collect(&:id), :back_url => @back},
119 :method => :post, :confirm => l(:text_issues_destroy_confirmation), :class => 'icon-del', :disabled => !@can[:delete] %></li>
119 :method => :post, :confirm => l(:text_issues_destroy_confirmation), :class => 'icon-del', :disabled => !@can[:delete] %></li>
120
120
121 <%= call_hook(:view_issues_context_menu_end, {:issues => @issues, :can => @can, :back => @back }) %>
121 <%= call_hook(:view_issues_context_menu_end, {:issues => @issues, :can => @can, :back => @back }) %>
@@ -79,14 +79,15 class ContextMenusControllerTest < ActionController::TestCase
79 :class => 'icon-del' }
79 :class => 'icon-del' }
80 end
80 end
81
81
82 def test_context_menu_multiple_issues_of_different_project
82 def test_context_menu_multiple_issues_of_different_projects
83 @request.session[:user_id] = 2
83 @request.session[:user_id] = 2
84 get :issues, :ids => [1, 2, 4]
84 get :issues, :ids => [1, 2, 6]
85 assert_response :success
85 assert_response :success
86 assert_template 'context_menu'
86 assert_template 'context_menu'
87 ids = "ids%5B%5D=1&amp;ids%5B%5D=2&amp;ids%5B%5D=6"
87 assert_tag :tag => 'a', :content => 'Delete',
88 assert_tag :tag => 'a', :content => 'Delete',
88 :attributes => { :href => '#',
89 :attributes => { :href => "/issues/destroy?#{ids}",
89 :class => 'icon-del disabled' }
90 :class => 'icon-del' }
90 end
91 end
91
92
92 end
93 end
@@ -1061,6 +1061,13 class IssuesControllerTest < ActionController::TestCase
1061 assert_equal 2, TimeEntry.find(2).issue_id
1061 assert_equal 2, TimeEntry.find(2).issue_id
1062 end
1062 end
1063
1063
1064 def test_destroy_issues_from_different_projects
1065 @request.session[:user_id] = 2
1066 post :destroy, :ids => [1, 2, 6], :todo => 'destroy'
1067 assert_redirected_to :controller => 'issues', :action => 'index'
1068 assert !(Issue.find_by_id(1) || Issue.find_by_id(2) || Issue.find_by_id(6))
1069 end
1070
1064 def test_default_search_scope
1071 def test_default_search_scope
1065 get :index
1072 get :index
1066 assert_tag :div, :attributes => {:id => 'quick-search'},
1073 assert_tag :div, :attributes => {:id => 'quick-search'},
General Comments 0
You need to be logged in to leave comments. Login now