Merged r15952 and r15953 (#23922).

git-svn-id: http://svn.redmine.org/redmine/branches/3.3-stable@16043 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang
2016-12-03 08:38:40 +00:00
parent 9160c401e3
commit bde77eebe3
2 changed files with 10 additions and 4 deletions

View File

@@ -59,7 +59,10 @@ class ContextMenusController < ApplicationController
end end
def time_entries 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? (render_404; return) unless @time_entries.present?
if (@time_entries.size == 1) if (@time_entries.size == 1)
@time_entry = @time_entries.first @time_entry = @time_entries.first
@@ -67,7 +70,7 @@ class ContextMenusController < ApplicationController
@projects = @time_entries.collect(&:project).compact.uniq @projects = @time_entries.collect(&:project).compact.uniq
@project = @projects.first if @projects.size == 1 @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)} edit_allowed = @time_entries.all? {|t| t.editable_by?(User.current)}
@can = {:edit => edit_allowed, :delete => edit_allowed} @can = {:edit => edit_allowed, :delete => edit_allowed}

View File

@@ -170,7 +170,7 @@ class TimelogController < ApplicationController
end end
def bulk_edit def bulk_edit
@available_activities = TimeEntryActivity.shared.active @available_activities = @projects.map(&:activities).reduce(:&)
@custom_fields = TimeEntry.first.available_custom_fields @custom_fields = TimeEntry.first.available_custom_fields
end end
@@ -236,7 +236,10 @@ private
end end
def find_time_entries 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 ActiveRecord::RecordNotFound if @time_entries.empty?
raise Unauthorized unless @time_entries.all? {|t| t.editable_by?(User.current)} raise Unauthorized unless @time_entries.all? {|t| t.editable_by?(User.current)}
@projects = @time_entries.collect(&:project).compact.uniq @projects = @time_entries.collect(&:project).compact.uniq