From: Jean-Philippe Lang Date: Sat, 3 Dec 2016 08:38:40 +0000 (+0000) Subject: Merged r15952 and r15953 (#23922). X-Git-Tag: 3.3.2~19 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=bde77eebe301f1463e7791025b583fb7a031447a;p=redmine.git Merged r15952 and r15953 (#23922). git-svn-id: http://svn.redmine.org/redmine/branches/3.3-stable@16043 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- diff --git a/app/controllers/context_menus_controller.rb b/app/controllers/context_menus_controller.rb index dc8e72609..903f13f00 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).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} diff --git a/app/controllers/timelog_controller.rb b/app/controllers/timelog_controller.rb index 7e4d6b71d..acb106d3b 100644 --- a/app/controllers/timelog_controller.rb +++ b/app/controllers/timelog_controller.rb @@ -170,7 +170,7 @@ class TimelogController < ApplicationController end def bulk_edit - @available_activities = TimeEntryActivity.shared.active + @available_activities = @projects.map(&:activities).reduce(:&) @custom_fields = TimeEntry.first.available_custom_fields end @@ -236,7 +236,10 @@ private end def find_time_entries - @time_entries = TimeEntry.where(:id => params[:id] || params[:ids]).to_a + @time_entries = TimeEntry.where(:id => params[:id] || params[:ids]). + preload(:project => :time_entry_activities). + preload(:user).to_a + raise ActiveRecord::RecordNotFound if @time_entries.empty? raise Unauthorized unless @time_entries.all? {|t| t.editable_by?(User.current)} @projects = @time_entries.collect(&:project).compact.uniq