Browse Source

Remove unused code

CLDC-3465-update-setup-question-link
Kat 9 months ago
parent
commit
55158f3ddd
  1. 50
      app/controllers/check_errors_controller.rb

50
app/controllers/check_errors_controller.rb

@ -23,53 +23,3 @@ private
end
end
end
# def restore_error_field_values(questions)
# return unless questions
# questions.each do |question|
# if question&.type == "date" && @log.attributes.key?(question.id)
# @log[question.id] = @log.send("#{question.id}_was")
# end
# end
# end
def responses_for_page(page)
page.questions.each_with_object({}) do |question, result|
question_params = params[@log.model_name.param_key][question.id]
if question.type == "date"
day = params[@log.model_name.param_key]["#{question.id}(3i)"]
month = params[@log.model_name.param_key]["#{question.id}(2i)"]
year = params[@log.model_name.param_key]["#{question.id}(1i)"]
next unless [day, month, year].any?(&:present?)
result[question.id] = if Date.valid_date?(year.to_i, month.to_i, day.to_i) && year.to_i.positive?
Date.new(year.to_i, month.to_i, day.to_i)
else
Date.new(0, 1, 1)
end
end
if question.id == "saledate" && set_managing_organisation_to_assigned_to_organisation?(result["saledate"])
result["managing_organisation_id"] = @log.assigned_to.organisation_id
end
next unless question_params
if %w[checkbox validation_override].include?(question.type)
question.answer_keys_without_dividers.each do |option|
result[option] = question_params.include?(option) ? 1 : 0
end
else
result[question.id] = question_params
end
if question.id == "owning_organisation_id"
owning_organisation = result["owning_organisation_id"].present? ? Organisation.find(result["owning_organisation_id"]) : nil
result["managing_organisation_id"] = owning_organisation.id if set_managing_organisation_to_owning_organisation?(owning_organisation)
end
result
end
end

Loading…
Cancel
Save