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
@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}
end
def bulk_edit
- @available_activities = TimeEntryActivity.shared.active
+ @available_activities = @projects.map(&:activities).reduce(:&)
@custom_fields = TimeEntry.first.available_custom_fields
end
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