Skip to content

Commit 20093d2

Browse files
Merge branch 'development' into fix-template-save
2 parents beaaa93 + b99cadc commit 20093d2

11 files changed

Lines changed: 75 additions & 12 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,13 @@
77
- Added popover for org profile page and added explanation for public plan
88
### Fixed
99

10+
- Froze mail gem version [#3254](https://github.com/DMPRoadmap/roadmap/issues/3254)
11+
- Updated the CSV export so that it now includes research outputs
12+
- Updated sans-serif font used in PDF downloads to Roboto since Google API no longer offers Helvetica
13+
- Fixed discrepencies with default/max per_page values for API and UI pagination
1014
- Updated JS that used to call the TinyMCE `setMode()` function so that it now calls `mode.set()` because the former is now deprecated.
1115
- Patched an issue that was causing a template's visibility to change to 'organizationally_visible' when saving on the template details page.
16+
- Fixed an issue with the Rails 6 keyword arguments change that was causing the `paginable_sort_link` to fail
1217

1318
### Changed
1419

Gemfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,11 @@ gem 'dotenv-rails'
218218

219219
gem 'activerecord_json_validator'
220220

221+
# We need to freeze the mail gem version as the recently released 2.8.0 triggers an exception
222+
# We will need to check if it's fixed when we migrate to Ruby 3.0/3.1
223+
# See : https://github.com/DMPRoadmap/roadmap/issues/3254
224+
gem 'mail', '2.7.1'
225+
221226
# ================================= #
222227
# ENVIRONMENT SPECIFIC DEPENDENCIES #
223228
# ================================= #

Gemfile.lock

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -579,6 +579,7 @@ DEPENDENCIES
579579
kaminari
580580
ledermann-rails-settings
581581
listen
582+
mail (= 2.7.1)
582583
mimemagic
583584
mocha
584585
mysql2
@@ -624,4 +625,4 @@ RUBY VERSION
624625
ruby 2.7.6p219
625626

626627
BUNDLED WITH
627-
2.3.25
628+
2.3.26

app/controllers/api/v0/plans_controller.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,11 @@ def index
9898
plan_ids = extract_param_list(params, 'plan')
9999
@plans = @plans.where(id: plan_ids) if plan_ids.present?
100100
# apply pagination after filtering
101-
@args = { per_page: params[:per_page], page: params[:page] }
101+
max_per_page = Rails.configuration.x.application.api_max_page_size
102+
page = params.fetch('page', 1).to_i
103+
per_page = params.fetch('per_page', max_per_page).to_i
104+
per_page = max_per_page if @per_page > max_per_page
105+
@args = { per_page: per_page, page: page }
102106
@plans = refine_query(@plans)
103107
respond_with @plans
104108
end

app/controllers/api/v1/base_api_controller.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,10 @@ def base_response_content
6060
# Retrieve the requested pagination params or use defaults
6161
# only allow 100 per page as the max
6262
def pagination_params
63+
max_per_page = Rails.configuration.x.application.api_max_page_size
6364
@page = params.fetch('page', 1).to_i
64-
@per_page = params.fetch('per_page', 20).to_i
65-
@per_page = 100 if @per_page > 100
65+
@per_page = params.fetch('per_page', max_per_page).to_i
66+
@per_page = max_per_page if @per_page > max_per_page
6667
end
6768

6869
# Parse the body of the incoming request

app/controllers/concerns/paginable.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ def refine_query(scope)
156156
if @args[:page] != 'ALL'
157157
# Can raise error if page is not a number
158158
scope = scope.page(@args[:page])
159-
.per(@args.fetch(:per_page, Rails.configuration.x.application.api_max_page_size))
159+
.per(@args.fetch(:per_page, Rails.configuration.x.results_per_page))
160160
end
161161
scope
162162
end
@@ -200,7 +200,7 @@ def sort_link_url(sort_field)
200200
end
201201
base_url = paginable_base_url(query_params[:page])
202202
sort_url = URI(base_url)
203-
sort_url.query = stringify_query_params(query_params)
203+
sort_url.query = stringify_query_params(**query_params)
204204
sort_url.to_s
205205
"#{sort_url}&#{stringify_nonpagination_query_params}"
206206
end

app/controllers/plan_exports_controller.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ def show_csv
7373
@show_unanswered,
7474
@selected_phase,
7575
@show_custom_sections,
76-
@show_coversheet),
76+
@show_coversheet,
77+
@show_research_outputs),
7778
filename: "#{file_name}.csv"
7879
end
7980

app/helpers/exports_helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ module ExportsHelper
1010
}.freeze
1111

1212
def font_face
13-
@formatting[:font_face].presence || 'Arial, Helvetica, Sans-Serif'
13+
@formatting[:font_face].presence || 'Roboto, Arial, Sans-Serif'
1414
end
1515

1616
def font_size

app/models/concerns/exportable_plan.rb

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ def as_csv(user,
2222
unanswered = true,
2323
selected_phase = nil,
2424
show_custom_sections = true,
25-
show_coversheet = false)
25+
show_coversheet = false,
26+
show_research_outputs = false)
2627
hash = prepare(user, show_coversheet)
2728
CSV.generate do |csv|
2829
prepare_coversheet_for_csv(csv, headings, hash) if show_coversheet
@@ -50,6 +51,10 @@ def as_csv(user,
5051
end
5152
end
5253
end
54+
csv << []
55+
csv << []
56+
57+
prepare_research_outputs_for_csv(csv, headings, hash) if show_research_outputs
5358
end
5459
end
5560
# rubocop:enable Style/OptionalBooleanParameter
@@ -93,6 +98,9 @@ def prepare(user, coversheet = false)
9398
end
9499
hash[:phases] = phases
95100

101+
# include any research outputs
102+
hash[:research_outputs] = prepare_research_outputs
103+
96104
record_plan_export(user, :pdf)
97105

98106
hash
@@ -138,6 +146,29 @@ def prepare_coversheet
138146
end
139147
# rubocop:enable Metrics/AbcSize
140148

149+
# rubocop:disable Metrics/AbcSize
150+
def prepare_research_outputs
151+
research_outputs.map do |research_output|
152+
presenter = ResearchOutputPresenter.new(research_output: research_output)
153+
size_hash = presenter.converted_file_size(size: research_output.byte_size)
154+
155+
{
156+
title: research_output.title,
157+
description: research_output.description,
158+
type: presenter.display_type,
159+
anticipated_release_date: presenter.display_release,
160+
initial_access_level: presenter.display_access,
161+
intended_repositories: presenter.display_repository&.join(', '),
162+
anticipated_file_size: "#{size_hash[:size]} #{size_hash[:unit]&.upcase}",
163+
initial_license: presenter.display_license,
164+
metadata_standards: presenter.display_metadata_standard&.join(', '),
165+
may_contain_sensitive_data: presenter.display_boolean(value: research_output.sensitive_data),
166+
may_contain_pii: presenter.display_boolean(value: research_output.personal_data)
167+
}
168+
end
169+
end
170+
# rubocop:enable Metrics/AbcSize
171+
141172
# rubocop:disable Metrics/AbcSize
142173
def prepare_coversheet_for_csv(csv, _headings, hash)
143174
csv << [_('Title: '), format(_('%{title}'), title: title)]
@@ -183,6 +214,21 @@ def prepare_coversheet_for_csv(csv, _headings, hash)
183214
end
184215
# rubocop:enable Metrics/MethodLength, Metrics/AbcSize
185216

217+
# rubocop:disable Metrics/AbcSize
218+
def prepare_research_outputs_for_csv(csv, _headings, hash)
219+
return false unless hash[:research_outputs].present? && hash[:research_outputs].any?
220+
221+
csv << [_('Research Outputs: ')]
222+
# Convert the hash keys to column headers
223+
csv << hash[:research_outputs].first.keys.map { |key| key.to_s.capitalize.gsub('_', ' ') }
224+
hash[:research_outputs].each do |research_output|
225+
csv << research_output.values
226+
end
227+
csv << []
228+
csv << []
229+
end
230+
# rubocop:enable Metrics/AbcSize
231+
186232
# rubocop:disable Metrics/AbcSize, Metrics/BlockLength, Metrics/MethodLength
187233
# rubocop:disable Metrics/ParameterLists
188234
def show_section_for_csv(csv, phase, section, headings, unanswered, hash)

app/models/settings/template.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ module Settings
1818
class Template < RailsSettings::SettingObject
1919
VALID_FONT_FACES = [
2020
'"Times New Roman", Times, Serif',
21-
'Arial, Helvetica, Sans-Serif'
21+
'Roboto, Arial, Sans-Serif'
2222
].freeze
2323

2424
VALID_FONT_SIZE_RANGE = (8..14).freeze

0 commit comments

Comments
 (0)