Skip to content

Commit

Permalink
Merge pull request #3108 from DMPRoadmap/development
Browse files Browse the repository at this point in the history
Merge Development for v3.0.5
  • Loading branch information
briri authored Feb 14, 2022
2 parents d707bed + 0e2df4e commit c76d896
Show file tree
Hide file tree
Showing 60 changed files with 11,431 additions and 10,755 deletions.
130 changes: 64 additions & 66 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,51 +1,51 @@
GEM
remote: https://rubygems.org/
specs:
actioncable (5.2.6)
actionpack (= 5.2.6)
actioncable (5.2.6.2)
actionpack (= 5.2.6.2)
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
actionmailer (5.2.6)
actionpack (= 5.2.6)
actionview (= 5.2.6)
activejob (= 5.2.6)
actionmailer (5.2.6.2)
actionpack (= 5.2.6.2)
actionview (= 5.2.6.2)
activejob (= 5.2.6.2)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 2.0)
actionpack (5.2.6)
actionview (= 5.2.6)
activesupport (= 5.2.6)
actionpack (5.2.6.2)
actionview (= 5.2.6.2)
activesupport (= 5.2.6.2)
rack (~> 2.0, >= 2.0.8)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
actionview (5.2.6)
activesupport (= 5.2.6)
actionview (5.2.6.2)
activesupport (= 5.2.6.2)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.3)
activejob (5.2.6)
activesupport (= 5.2.6)
activejob (5.2.6.2)
activesupport (= 5.2.6.2)
globalid (>= 0.3.6)
activemodel (5.2.6)
activesupport (= 5.2.6)
activerecord (5.2.6)
activemodel (= 5.2.6)
activesupport (= 5.2.6)
activemodel (5.2.6.2)
activesupport (= 5.2.6.2)
activerecord (5.2.6.2)
activemodel (= 5.2.6.2)
activesupport (= 5.2.6.2)
arel (>= 9.0)
activestorage (5.2.6)
actionpack (= 5.2.6)
activerecord (= 5.2.6)
activestorage (5.2.6.2)
actionpack (= 5.2.6.2)
activerecord (= 5.2.6.2)
marcel (~> 1.0.0)
activesupport (5.2.6)
activesupport (5.2.6.2)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 0.7, < 2)
minitest (~> 5.1)
tzinfo (~> 1.1)
addressable (2.8.0)
public_suffix (>= 2.0.2, < 5.0)
annotate (3.1.1)
activerecord (>= 3.2, < 7.0)
annotate (3.2.0)
activerecord (>= 3.2, < 8.0)
rake (>= 10.4, < 14.0)
annotate_gem (0.0.14)
bundler (>= 1.1)
Expand All @@ -62,9 +62,9 @@ GEM
bindex (0.8.1)
binding_of_caller (1.0.0)
debug_inspector (>= 0.0.1)
bootsnap (1.10.2)
bootsnap (1.10.3)
msgpack (~> 1.2)
brakeman (5.2.0)
brakeman (5.2.1)
builder (3.2.4)
bullet (7.0.1)
activesupport (>= 3.0.0)
Expand Down Expand Up @@ -131,7 +131,7 @@ GEM
dragonfly (~> 1.0)
fog-aws
erubi (1.10.0)
excon (0.90.0)
excon (0.91.0)
execjs (2.8.1)
factory_bot (6.2.0)
activesupport (>= 5.0.0)
Expand Down Expand Up @@ -165,11 +165,10 @@ GEM
faraday-retry (1.0.3)
ffi (1.15.5)
flag_shih_tzu (0.3.23)
fog-aws (3.12.0)
fog-aws (3.13.0)
fog-core (~> 2.1)
fog-json (~> 1.1)
fog-xml (~> 0.1)
ipaddress (~> 0.8)
fog-core (2.2.4)
builder
excon (~> 0.71)
Expand Down Expand Up @@ -218,9 +217,8 @@ GEM
httparty (0.20.0)
mime-types (~> 3.0)
multi_xml (>= 0.5.2)
i18n (1.8.11)
i18n (1.9.1)
concurrent-ruby (~> 1.0)
ipaddress (0.8.3)
jbuilder (2.11.5)
actionview (>= 5.0.0)
activesupport (>= 5.0.0)
Expand All @@ -246,7 +244,7 @@ GEM
rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10)
locale (2.1.3)
loofah (2.13.0)
loofah (2.14.0)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
lumberjack (1.2.8)
Expand Down Expand Up @@ -296,7 +294,7 @@ GEM
omniauth-orcid (2.1.1)
omniauth-oauth2 (~> 1.3)
ruby_dig (~> 0.0.2)
omniauth-rails_csrf_protection (1.0.0)
omniauth-rails_csrf_protection (1.0.1)
actionpack (>= 4.2)
omniauth (~> 2.0)
omniauth-shibboleth (1.3.0)
Expand All @@ -306,7 +304,7 @@ GEM
parallel (1.21.0)
parser (3.1.0.0)
ast (~> 2.4.1)
pg (1.3.0)
pg (1.3.2)
prime (0.1.2)
forwardable
singleton
Expand All @@ -317,9 +315,9 @@ GEM
coderay (~> 1.1)
method_source (~> 1.0)
public_suffix (4.0.6)
puma (5.6.0)
puma (5.6.2)
nio4r (~> 2.0)
pundit (2.1.1)
pundit (2.2.0)
activesupport (>= 3.0.0)
pundit-matchers (1.7.0)
rspec-rails (>= 3.0.0)
Expand All @@ -333,18 +331,18 @@ GEM
rack
rack-test (1.1.0)
rack (>= 1.0, < 3)
rails (5.2.6)
actioncable (= 5.2.6)
actionmailer (= 5.2.6)
actionpack (= 5.2.6)
actionview (= 5.2.6)
activejob (= 5.2.6)
activemodel (= 5.2.6)
activerecord (= 5.2.6)
activestorage (= 5.2.6)
activesupport (= 5.2.6)
rails (5.2.6.2)
actioncable (= 5.2.6.2)
actionmailer (= 5.2.6.2)
actionpack (= 5.2.6.2)
actionview (= 5.2.6.2)
activejob (= 5.2.6.2)
activemodel (= 5.2.6.2)
activerecord (= 5.2.6.2)
activestorage (= 5.2.6.2)
activesupport (= 5.2.6.2)
bundler (>= 1.3.0)
railties (= 5.2.6)
railties (= 5.2.6.2)
sprockets-rails (>= 2.0.0)
rails-controller-testing (1.0.5)
actionpack (>= 5.0.1.rc1)
Expand All @@ -355,39 +353,39 @@ GEM
nokogiri (>= 1.6)
rails-html-sanitizer (1.4.2)
loofah (~> 2.3)
railties (5.2.6)
actionpack (= 5.2.6)
activesupport (= 5.2.6)
railties (5.2.6.2)
actionpack (= 5.2.6.2)
activesupport (= 5.2.6.2)
method_source
rake (>= 0.8.7)
thor (>= 0.19.0, < 2.0)
rainbow (3.1.1)
rake (13.0.6)
rb-fsevent (0.11.0)
rb-fsevent (0.11.1)
rb-inotify (0.10.1)
ffi (~> 1.0)
recaptcha (5.8.1)
json
regexp_parser (2.2.0)
regexp_parser (2.2.1)
responders (3.0.1)
actionpack (>= 5.0)
railties (>= 5.0)
rexml (3.2.5)
rollbar (3.3.0)
rspec (3.10.0)
rspec-core (~> 3.10.0)
rspec-expectations (~> 3.10.0)
rspec-mocks (~> 3.10.0)
rspec (3.11.0)
rspec-core (~> 3.11.0)
rspec-expectations (~> 3.11.0)
rspec-mocks (~> 3.11.0)
rspec-collection_matchers (1.2.0)
rspec-expectations (>= 2.99.0.beta1)
rspec-core (3.10.1)
rspec-support (~> 3.10.0)
rspec-expectations (3.10.2)
rspec-core (3.11.0)
rspec-support (~> 3.11.0)
rspec-expectations (3.11.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.10.0)
rspec-mocks (3.10.2)
rspec-support (~> 3.11.0)
rspec-mocks (3.11.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.10.0)
rspec-support (~> 3.11.0)
rspec-rails (5.1.0)
actionpack (>= 5.2)
activesupport (>= 5.2)
Expand All @@ -396,8 +394,8 @@ GEM
rspec-expectations (~> 3.10)
rspec-mocks (~> 3.10)
rspec-support (~> 3.10)
rspec-support (3.10.3)
rubocop (1.25.0)
rspec-support (3.11.0)
rubocop (1.25.1)
parallel (~> 1.10)
parser (>= 3.1.0.0)
rainbow (>= 2.2.2, < 4.0)
Expand All @@ -406,7 +404,7 @@ GEM
rubocop-ast (>= 1.15.1, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 3.0)
rubocop-ast (1.15.1)
rubocop-ast (1.15.2)
parser (>= 3.0.1.1)
rubocop-i18n (3.0.0)
rubocop (~> 1.0)
Expand Down Expand Up @@ -467,7 +465,7 @@ GEM
thread_safe (0.3.6)
tilt (2.0.10)
tomparse (0.4.2)
translation (1.28)
translation (1.29)
gettext (~> 3.2, >= 3.2.5, <= 3.4.2)
turbolinks (5.2.1)
turbolinks-source (~> 5.2)
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/api/v0/base_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def index
plural_resource_name = "@#{resource_name.pluralize}"
resources = resource_class.where(query_params)
.page(page_params[:page])
.per(page_params[:page_size])
.per(page_params[:per_page])

instance_variable_set(plural_resource_name, resources)
respond_with instance_variable_get(plural_resource_name)
Expand Down Expand Up @@ -71,7 +71,7 @@ def query_params
#
# Returns Hash
def page_params
params.permit(:page, :page_size)
params.permit(:page, :per_page)
end

# The resource class based on the controller
Expand Down
1 change: 1 addition & 0 deletions app/controllers/api/v0/plans_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class PlansController < Api::V0::BaseController
include Paginable

before_action :authenticate
before_action :page_params, except: %i[heartbeat]

##
# Creates a new plan based on the information passed in JSON to the API
Expand Down
3 changes: 2 additions & 1 deletion app/controllers/concerns/paginable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ def refine_query(scope)
if @args[:page] != 'ALL'
# Can raise error if page is not a number
scope = scope.page(@args[:page])
.per(@args.fetch(:per_page, Rails.configuration.x.application.api_max_page_size))
end
scope
end
Expand All @@ -179,7 +180,7 @@ def sort_link_name(sort_field)
style="float: right; font-size: 1.2em;">
<span class="screen-reader-text">
#{format(_('Sort by %<sort_field>s'), sort_field: sort_field.split('.').first)}
#{format(_('Sort by %<sort_field>'), sort_field: sort_field.split('.').first)}
</span>
</i>
HTML
Expand Down
9 changes: 5 additions & 4 deletions app/controllers/paginable/plans_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,17 @@ def org_admin
end
# rubocop:enable Metrics/AbcSize

# GET /paginable/plans/org_admin/:page
def org_admin_other_user
# GET /paginable/users/:id/plans
def index
@user = User.find(params[:id])
authorize @user
raise Pundit::NotAuthorizedError unless current_user.present? && current_user.can_org_admin? && @user.present?

paginable_renderise(
partial: 'org_admin_other_user',
partial: 'index',
scope: Plan.active(@user),
query_params: { sort_field: 'plans.updated_at', sort_direction: :desc }
query_params: { sort_field: 'plans.updated_at', sort_direction: :desc },
format: :json
)
end
end
Expand Down
3 changes: 2 additions & 1 deletion app/controllers/super_admin/orgs_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,8 @@ def org_params
params.require(:org).permit(:name, :abbreviation, :logo, :managed,
:contact_email, :contact_name,
:remove_logo, :feedback_enabled, :feedback_msg,
:org_id, :org_name, :org_crosswalk)
:org_id, :org_name, :org_crosswalk,
:funder, :institution, :organisation)
end

def merge_params
Expand Down
11 changes: 5 additions & 6 deletions app/models/concerns/exportable_plan.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,10 @@ def prepare(user, coversheet = false)
# rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
def prepare_coversheet
hash = {}
# name of owner and any co-owners
attribution = owner.present? ? [owner.name(false)] : []
roles.administrator.not_creator.each do |role|
attribution << role.user.name(false)
end
# Use the name of the DMP owner/creator OR the first Co-owner if there is no
# owner for some reason
attribution = roles.creator.first&.user&.name(false)
roles.administrator.not_creator.first&.user&.name(false) unless attribution.present?
hash[:attribution] = attribution

# Org name of plan owner's org
Expand Down Expand Up @@ -175,7 +174,7 @@ def show_section_for_csv(csv, phase, section, headings, unanswered, hash)
answer_text = ''
if answer.present?
answer_text += answer.question_options.pluck(:text).join(', ') if answer.question_options.any?
answer_text += answer.text if answer.answered?
answer_text += answer.text if answer.answered? && answer.text.present?
elsif unanswered
answer_text += _('Not Answered')
end
Expand Down
16 changes: 13 additions & 3 deletions app/models/contributor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,20 @@ def merge(other)

private

# rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity
def name_or_email_presence
return true unless name.blank? && email.blank?
errors.add(:name, _("can't be blank.")) if name.blank? && Rails.configuration.x.application.require_contributor_name
if email.blank? && Rails.configuration.x.application.require_contributor_email
errors.add(:email,
_("can't be blank."))
end

if name.blank? && email.blank? && errors.size.zero?
errors.add(:name, _("can't be blank if no email is provided."))
errors.add(:email, _("can't be blank if no name is provided."))
end

errors.add(:name, _("can't be blank if no email is provided"))
errors.add(:email, _("can't be blank if no name is provided"))
errors.size.zero?
end
# rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity
end
Loading

0 comments on commit c76d896

Please sign in to comment.