From 7df417e63a275dfa711ebe5a52c2083698fccc20 Mon Sep 17 00:00:00 2001 From: Suzanne Vogt Date: Sun, 13 Mar 2022 22:55:03 -0400 Subject: [PATCH] Salesforce - doi_estimate_year_one field. (Allow doi_estimate to be set for any org type.) --- app/models/provider.rb | 36 ++++++++++++++---------------------- 1 file changed, 14 insertions(+), 22 deletions(-) diff --git a/app/models/provider.rb b/app/models/provider.rb index f742696a4..898d9feb3 100644 --- a/app/models/provider.rb +++ b/app/models/provider.rb @@ -840,24 +840,20 @@ def activity_id_not_changed end def doi_estimate_field - if member_type == "consortium_organization" - begin - num = Integer(doi_estimate) - if num < 0 - errors.add( - :doi_estimate, - :doi_estimate_invalid, - value: "The doi_estimate must be a nonnegative integer.", - ) - end - rescue - errors.add( - :doi_estimate, - :doi_estimate_invalid, - value: "The doi_estimate must be a nonnegative integer.", - ) - end + num = Integer(doi_estimate) + if num < 0 + errors.add( + :doi_estimate, + :doi_estimate_invalid, + value: "The doi_estimate must be a nonnegative integer.", + ) end + rescue + errors.add( + :doi_estimate, + :doi_estimate_invalid, + value: "The doi_estimate must be a nonnegative integer.", + ) end # attributes to be sent to elasticsearch index @@ -947,11 +943,7 @@ def set_defaults self.billing_information = {} if billing_information.blank? self.consortium_id = nil unless member_type == "consortium_organization" self.non_profit_status = "non-profit" if non_profit_status.blank? - if member_type == "consortium_organization" - self.doi_estimate = doi_estimate.to_i - else - self.doi_estimate = 0 - end + self.doi_estimate = doi_estimate.to_i # custom filename for attachment as data URLs don't support filenames if logo_content_type.present?