Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions app/controllers/plan_exports_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@ def show
.detect { |p| p.visibility_allowed?(@plan) }
end

# Added contributors to coverage of plans.
# Users will see both roles and contributor names if the role is filled
@hash[:data_curation] = Contributor.where(plan_id: @plan.id).data_curation
@hash[:investigation] = Contributor.where(plan_id: @plan.id).investigation
@hash[:pa] = Contributor.where(plan_id: @plan.id).project_administration
@hash[:other] = Contributor.where(plan_id: @plan.id).other

respond_to do |format|
format.html { show_html }
format.csv { show_csv }
Expand Down
28 changes: 25 additions & 3 deletions app/models/concerns/exportable_plan.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,9 @@ def prepare(user, coversheet = false)

hash
end
# rubocop:enable Metrics/MethodLength, Metrics/AbcSize

# rubocop:enable Style/OptionalBooleanParameter

# rubocop:disable Metrics/AbcSize
# rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
def prepare_coversheet
hash = {}
Expand All @@ -110,6 +109,13 @@ def prepare_coversheet
roles.administrator.not_creator.first&.user&.name(false) unless attribution.present?
hash[:attribution] = attribution

# Added contributors to coverage of plans.
# Users will see both roles and contributor names if the role is filled
hash[:data_curation] = Contributor.where(plan_id: id).data_curation
hash[:investigation] = Contributor.where(plan_id: id).investigation
hash[:pa] = Contributor.where(plan_id: id).project_administration
hash[:other] = Contributor.where(plan_id: id).other

# Org name of plan owner's org
hash[:affiliation] = owner.present? ? owner.org.name : ''

Expand All @@ -132,13 +138,29 @@ def prepare_coversheet
end
# rubocop:enable Metrics/AbcSize

# rubocop:disable Metrics/MethodLength, Metrics/AbcSize
# rubocop:disable Metrics/AbcSize
def prepare_coversheet_for_csv(csv, _headings, hash)
csv << [_('Title: '), format(_('%{title}'), title: title)]
csv << if Array(hash[:attribution]).many?
[_('Creators: '), format(_('%{authors}'), authors: Array(hash[:attribution]).join(', '))]
else
[_('Creator:'), format(_('%{authors}'), authors: hash[:attribution])]
end
if hash[:investigation].present?
csv << [_('Principal Investigator: '),
format(_('%{investigation}'), investigation: hash[:investigation].map(&:name).join(', '))]
end
if hash[:data_curation].present?
csv << [_('Date Manager: '),
format(_('%{data_curation}'), data_curation: hash[:data_curation].map(&:name).join(', '))]
end
if hash[:pa].present?
csv << [_('Project Administrator: '), format(_('%{pa}'), pa: hash[:pa].map(&:name).join(', '))]
end
if hash[:other].present?
csv << [_('Contributor: '), format(_('%{other}'), other: hash[:other].map(&:name).join(', '))]
end
csv << [_('Affiliation: '), format(_('%{affiliation}'), affiliation: hash[:affiliation])]
csv << ['Affiliation: ', format(_('%{affiliation}'), affiliation: hash[:affiliation])]
csv << if hash[:funder].present?
[_('Template: '), format(_('%{funder}'), funder: hash[:funder])]
Expand Down
16 changes: 16 additions & 0 deletions app/views/shared/export/_plan_coversheet.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,22 @@

<p><strong><%= _("Creator:") %></strong><%= @hash[:attribution] %></p><br>

<%# Added contributors to coverage of plans.
# Users will see both roles and contributor names if the role is filled %>
<%# Roles are ranked by PI -> DM -> PA -> Other (if any) %>
<% if @hash[:investigation].present? %>
<p><b><%= _("Principal Investigator: ") %></b><%= @hash[:investigation].map(&:name).join(', ') %></p><br>
<% end %>
<% if @hash[:data_curation].present? %>
<p><b><%= _("Data Manager: ") %></b><%= @hash[:data_curation].map(&:name).join(', ') %></p><br>
<% end %>
<% if @hash[:pa].present? %>
<p><b><%= _("Project Administrator: ") %></b><%= @hash[:pa].map(&:name).join(', ') %></p><br>
<% end %>
<% if @hash[:other].present? %>
<p><b><%= _("Contributor: ") %></b><%= @hash[:other].map(&:name).join(', ') %></p><br>
<% end %>

<p><b><%= _("Affiliation: ") %></b><%= @hash[:affiliation] %></p><br>

<% if @hash[:funder].present? %>
Expand Down
15 changes: 15 additions & 0 deletions app/views/shared/export/_plan_txt.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,21 @@
<%= "----------------------------------------------------------\n" %>
<% if @show_coversheet %>
<%= Array(@hash[:attribution]).many? ? _("Creators: ") + Array(@hash[:attribution]).join(", ") : _('Creator:') + @hash[:attribution] %>
<%# Added contributors to coverage of plans.
# Users will see both roles and contributor names if the role is filled %>
<%# Roles are ranked by PI -> DM -> PA -> Other (if any) %>
<% if @hash[:investigation].present? %>
<%= _("Principal Investigator: ") + @hash[:investigation].map(&:name).join(', ') %>
<% end %>
<% if @hash[:data_curation].present? %>
<%= _("Data Manager: ") + @hash[:data_curation].map(&:name).join(', ') %>
<% end %>
<% if @hash[:pa].present? %>
<%= _("Project Administrator: ") + @hash[:pa].map(&:name).join(', ') %>
<% end %>
<% if @hash[:other].present? %>
<%= _("Contributor: ") + @hash[:other].map(&:name).join(', ') %>
<% end %>
<%= _("Affiliation: ") + @hash[:affiliation] %>
<% if @hash[:funder].present? %>
<%= _("Template: ") + @hash[:funder] %>
Expand Down