Browse Source

refactor: move safe navigator and add shared org_params to log

pull/1169/head
natdeanlewissoftwire 3 years ago
parent
commit
ad165e1df9
  1. 8
      app/controllers/lettings_logs_controller.rb
  2. 1
      app/controllers/logs_controller.rb
  3. 7
      app/controllers/sales_logs_controller.rb
  4. 2
      app/services/filter_service.rb

8
app/controllers/lettings_logs_controller.rb

@ -102,11 +102,9 @@ class LettingsLogsController < LogsController
end
def org_params
{
"owning_organisation_id" => current_user.organisation.id,
"managing_organisation_id" => current_user.organisation.id,
"created_by_id" => current_user.id,
}
super.merge(
{ "managing_organisation_id" => current_user.organisation.id },
)
end
private

1
app/controllers/logs_controller.rb

@ -63,7 +63,6 @@ private
owning_organisation_id = current_user.organisation.holds_own_stock? ? current_user.organisation.id : nil
{
"owning_organisation_id" => owning_organisation_id,
"managing_organisation_id" => current_user.organisation.id,
"created_by_id" => current_user.id,
}
end

7
app/controllers/sales_logs_controller.rb

@ -43,11 +43,4 @@ class SalesLogsController < LogsController
def permitted_log_params
params.require(:sales_log).permit(SalesLog.editable_fields)
end
def org_params
{
"owning_organisation_id" => current_user.organisation.id,
"created_by_id" => current_user.id,
}
end
end

2
app/services/filter_service.rb

@ -18,7 +18,7 @@ class FilterService
end
logs = logs.order(created_at: :desc)
if user.support?
if logs&.first.lettings?
if logs.first&.lettings?
logs.all.includes(:owning_organisation, :managing_organisation)
else
logs.all.includes(:owning_organisation)

Loading…
Cancel
Save