Skip to content

Commit

Permalink
Merge pull request #3167 from pengyin-shan/development
Browse files Browse the repository at this point in the history
Add array judgement for creators in text and csv download
  • Loading branch information
briri committed May 2, 2022
2 parents 974b589 + ca859e7 commit 90090f7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions app/models/concerns/exportable_plan.rb
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,14 @@ def prepare_coversheet
hash
end
# rubocop:enable Metrics/AbcSize
# rubocop:enable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity

# rubocop:disable Metrics/MethodLength, Metrics/AbcSize
def prepare_coversheet_for_csv(csv, _headings, hash)
csv << [_('Creator:'), format(_('%{author}'), author: hash[:attribution])]
csv << if Array(hash[:attribution]).many?
[_('Creators: '), format(_('%{authors}'), authors: Array(hash[:attribution]).join(', '))]
else
[_('Creator:'), format(_('%{authors}'), authors: hash[:attribution])]
end
csv << ['Affiliation: ', format(_('%{affiliation}'), affiliation: hash[:affiliation])]
csv << if hash[:funder].present?
[_('Template: '), format(_('%{funder}'), funder: hash[:funder])]
Expand All @@ -160,7 +163,6 @@ def prepare_coversheet_for_csv(csv, _headings, hash)
# rubocop:enable Metrics/MethodLength, Metrics/AbcSize

# rubocop:disable Metrics/AbcSize, Metrics/BlockLength, Metrics/MethodLength
# rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
# rubocop:disable Metrics/ParameterLists
def show_section_for_csv(csv, phase, section, headings, unanswered, hash)
section[:questions].each do |question|
Expand Down
2 changes: 1 addition & 1 deletion app/views/shared/export/_plan_txt.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<%= "#{@plan.title}" %>
<%= "----------------------------------------------------------\n" %>
<% if @show_coversheet %>
<%= @hash[:attribution].length > 1 ? _("Creators: ") : _('Creator:') %> <%= @hash[:attribution].join(', ') %>
<%= Array(@hash[:attribution]).many? ? _("Creators: ") + Array(@hash[:attribution]).join(", ") : _('Creator:') + @hash[:attribution] %>
<%= _("Affiliation: ") + @hash[:affiliation] %>
<% if @hash[:funder].present? %>
<%= _("Template: ") + @hash[:funder] %>
Expand Down

0 comments on commit 90090f7

Please sign in to comment.