Migrate remaining scopes to use lambda/block

Signed-off-by: Alex Coles <alex@alexbcoles.com>
pull/6827/head
Alex Coles 9 years ago
parent 770a4a6097
commit 27d2ceacf2
  1. 5
      app/models/labor_budget_item.rb
  2. 5
      lib/open_project/costs/patches/time_entry_patch.rb

@ -40,9 +40,8 @@ class LaborBudgetItem < ActiveRecord::Base
end
scope :visible_costs, lambda{|*args|
{ include: [{ cost_object: :project }, :user],
conditions: LaborBudgetItem.visible_condition((args.first || User.current), args[1])
}
includes([{ cost_object: :project }, :user])
.where(LaborBudgetItem.visible_condition((args.first || User.current), args[1]))
}
def costs

@ -50,9 +50,8 @@ module OpenProject::Costs::Patches::TimeEntryPatch
(#{Project.allowed_to_condition(user, :view_own_hourly_rate, project: project)} AND #{TimeEntry.table_name}.user_id = #{user.id})) }
view_time_entries = TimeEntry.visible_condition(user, project)
{ include: [:project, :user],
conditions: [view_time_entries, view_hourly_rates].join(' AND ')
}
includes(:project, :user)
.where([view_time_entries, view_hourly_rates].join(' AND '))
}
end
end

Loading…
Cancel
Save