Skip to content

Commit

Permalink
shush a few hounds
Browse files Browse the repository at this point in the history
  • Loading branch information
cooperka committed Oct 12, 2023
1 parent 9114c7f commit 658df7a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
2 changes: 1 addition & 1 deletion app/controllers/forms_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
23 changes: 14 additions & 9 deletions app/models/forms/export.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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"?

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

0 comments on commit 658df7a

Please sign in to comment.