From 443239f3d549cf59ddc35096e2f5f599d54ddc28 Mon Sep 17 00:00:00 2001 From: Sam Seed Date: Wed, 4 Jan 2023 18:47:49 +0000 Subject: [PATCH] feat: update housing provider answer opts to include current HP in db --- app/models/form/lettings/questions/stock_owner.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/models/form/lettings/questions/stock_owner.rb b/app/models/form/lettings/questions/stock_owner.rb index dfc2209c3..67e747c1d 100644 --- a/app/models/form/lettings/questions/stock_owner.rb +++ b/app/models/form/lettings/questions/stock_owner.rb @@ -11,8 +11,14 @@ class Form::Lettings::Questions::StockOwner < ::Form::Question def answer_options answer_opts = { "" => "Select an option" } + return answer_opts unless ActiveRecord::Base.connected? return answer_opts unless current_user + return answer_opts unless log + + if log.owning_organisation_id.present? + answer_opts = answer_opts.merge({ log.owning_organisation.id => log.owning_organisation.name }) + end if !current_user.support? && current_user.organisation.holds_own_stock? answer_opts[current_user.organisation.id] = "#{current_user.organisation.name} (Your organisation)"