From 658df7ada8945183146e851a497ad2b005224b3a Mon Sep 17 00:00:00 2001 From: Kevin Cooper Date: Thu, 12 Oct 2023 17:49:55 -0400 Subject: [PATCH] shush a few hounds --- app/controllers/forms_controller.rb | 2 +- app/models/forms/export.rb | 23 ++++++++++++++--------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/app/controllers/forms_controller.rb b/app/controllers/forms_controller.rb index 36e90191e6..c8275277e4 100644 --- a/app/controllers/forms_controller.rb +++ b/app/controllers/forms_controller.rb @@ -238,7 +238,7 @@ def export_xml # XLSForm export. def export_xls exporter = Forms::Export.new(@form) - send_data(exporter.to_xls, filename: "xlsform-#{@form.name.dasherize}-#{Time.zone.today}.xls") + send_data(exporter.to_xls.html_safe, filename: "xlsform-#{@form.name.dasherize}-#{Time.zone.today}.xls") # rubocop:disable Rails/OutputSafety end # ODK XML export for all published forms. diff --git a/app/models/forms/export.rb b/app/models/forms/export.rb index 0a54cd8182..348dae92d3 100644 --- a/app/models/forms/export.rb +++ b/app/models/forms/export.rb @@ -38,11 +38,13 @@ class Export "video" => "video", "integer" => "integer", - # Not supported in XLSForm - "sketch" => "sketch (WARNING: not supported)", - "signature" => "signature (WARNING: not supported)" + # TODO: Not yet supported in our XLSForm exporter + "sketch" => "sketch (WARNING: not yet supported)", + "signature" => "signature (WARNING: not yet supported)" - # XLSForm qtypes not supported in NEMO: range, geotrace, geoshape, note, file, select_one_from_file, select_multiple_from_file, background-audio, calculate, acknowledge, hidden, xml-external + # Note: XLSForm qtypes not supported in NEMO: + # range, geotrace, geoshape, note, file, select_one_from_file, select_multiple_from_file, + # background-audio, calculate, acknowledge, hidden, xml-external }.freeze def initialize(form) @@ -58,7 +60,7 @@ def to_csv end end - # rubocop:disable Metrics/MethodLength, Metrics/BlockLength, Metrics/AbcSize, Metrics/PerceivedComplexity + # rubocop:disable Metrics/MethodLength, Metrics/BlockLength, Metrics/AbcSize, Metrics/PerceivedComplexity, Style/Next def to_xls # TODO: option set "levels"? @@ -116,7 +118,9 @@ def to_xls os.option_nodes.each_with_index do |node, x| if node.option.present? - choices.row(x + choices_index_mod).push(os.name, node.option.canonical_name, node.option.canonical_name) + choices + .row(x + choices_index_mod) + .push(os.name, node.option.canonical_name, node.option.canonical_name) end end @@ -156,9 +160,9 @@ def to_xls # Write file = StringIO.new book.write(file) - file.string.html_safe + file.string end - # rubocop:enable Metrics/MethodLength, Metrics/BlockLength, Metrics/AbcSize, Metrics/PerceivedComplexity + # rubocop:enable Metrics/MethodLength, Metrics/BlockLength, Metrics/AbcSize, Metrics/PerceivedComplexity, Style/Next private @@ -227,7 +231,8 @@ def conditions_to_xls(conditions, true_if) "#{relevant_to_push}#{left_to_push} #{op} #{right_to_push} #{concatenator} " end end - return relevant_to_push + + relevant_to_push end end end