From 88ab6dd946f07bca094de24491bc3c151d591d4d Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Fri, 18 Nov 2016 08:19:11 +0000 Subject: [PATCH] Time Entries context menu shows activities not available for the time entry's project (#23922). MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Patch by Felix Schäfer. git-svn-id: http://svn.redmine.org/redmine/trunk@15952 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/controllers/context_menus_controller.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/controllers/context_menus_controller.rb b/app/controllers/context_menus_controller.rb index e2b2f922d..e12aaabe4 100644 --- a/app/controllers/context_menus_controller.rb +++ b/app/controllers/context_menus_controller.rb @@ -59,7 +59,10 @@ class ContextMenusController < ApplicationController end def time_entries - @time_entries = TimeEntry.where(:id => params[:ids]).preload(:project, :user).to_a + @time_entries = TimeEntry.where(:id => params[:ids]). + preload(:project => :time_entry_activities). + preload(:user).to_a + (render_404; return) unless @time_entries.present? if (@time_entries.size == 1) @time_entry = @time_entries.first @@ -67,7 +70,7 @@ class ContextMenusController < ApplicationController @projects = @time_entries.collect(&:project).compact.uniq @project = @projects.first if @projects.size == 1 - @activities = TimeEntryActivity.shared.active + @activities = @projects.map(&:activities).reduce(:&) edit_allowed = @time_entries.all? {|t| t.editable_by?(User.current)} @can = {:edit => edit_allowed, :delete => edit_allowed} -- 2.39.5