From d5144d93907e39415517f9f9d9c534bcd45502fa Mon Sep 17 00:00:00 2001 From: John Pinto Date: Thu, 13 Jan 2022 12:13:19 +0000 Subject: [PATCH 1/7] DCC Issue 679 - Fix for issue that Super Admins unable to create new Orgs. Fix for DCC issue https://github.com/DigitalCurationCentre/DMPonline-Service/issues/679 Changes: - in app/controllers/super_admin/orgs_controller.rb added missing params to orgs_params method :funder, :institution, :organisation - in app/models/org.rb removed (as it is never set on Org creation) validates :abbreviation, presence: { message: PRESENCE_MESSAGE } - in app/views/orgs/_profile_form.html.erb removed :abbreviation required "aria-required": true - in app/views/shared/org_selectors/_external_only.html.erb renamed wrongly named text field :org_name to :name <%= form.label :name, label %> <%= form.text_field :name, class: "form-control autocomplete", --- app/controllers/super_admin/orgs_controller.rb | 3 ++- app/models/org.rb | 2 -- app/views/orgs/_profile_form.html.erb | 2 +- app/views/shared/org_selectors/_external_only.html.erb | 4 ++-- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/app/controllers/super_admin/orgs_controller.rb b/app/controllers/super_admin/orgs_controller.rb index 6e2c49634b..fd427143f9 100644 --- a/app/controllers/super_admin/orgs_controller.rb +++ b/app/controllers/super_admin/orgs_controller.rb @@ -150,7 +150,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 diff --git a/app/models/org.rb b/app/models/org.rb index de2526de38..666096684e 100644 --- a/app/models/org.rb +++ b/app/models/org.rb @@ -93,8 +93,6 @@ class Org < ApplicationRecord validates :name, presence: { message: PRESENCE_MESSAGE }, uniqueness: { message: UNIQUENESS_MESSAGE } - validates :abbreviation, presence: { message: PRESENCE_MESSAGE } - validates :is_other, inclusion: { in: BOOLEAN_VALUES, message: PRESENCE_MESSAGE } diff --git a/app/views/orgs/_profile_form.html.erb b/app/views/orgs/_profile_form.html.erb index 15971d2c3c..5226143c6d 100644 --- a/app/views/orgs/_profile_form.html.erb +++ b/app/views/orgs/_profile_form.html.erb @@ -25,7 +25,7 @@
<%= f.label :abbreviation, _('Organisation abbreviated name'), class: "control-label" %> - <%= f.text_field :abbreviation, id: "org_abbreviation", class: "form-control", "aria-required": true %> + <%= f.text_field :abbreviation, id: "org_abbreviation", class: "form-control" %>
<% end %> diff --git a/app/views/shared/org_selectors/_external_only.html.erb b/app/views/shared/org_selectors/_external_only.html.erb index daf0ef3456..9353e1c05a 100644 --- a/app/views/shared/org_selectors/_external_only.html.erb +++ b/app/views/shared/org_selectors/_external_only.html.erb @@ -13,8 +13,8 @@ presenter = OrgSelectionPresenter.new(orgs: [default_org], placeholder = _("Begin typing to see a list of suggestions.") %> -<%= form.label :org_name, label %> -<%= form.text_field :org_name, class: "form-control autocomplete", +<%= form.label :name, label %> +<%= form.text_field :name, class: "form-control autocomplete", placeholder: placeholder, value: presenter.name, spellcheck: true, From b419b18a1c10f15eb779230bc7a2f807d48a1098 Mon Sep 17 00:00:00 2001 From: John Pinto Date: Thu, 13 Jan 2022 12:13:19 +0000 Subject: [PATCH 2/7] DCC Issue 679 - Fix for issue that Super Admins unable to create new Orgs. Fix for DCC issue https://github.com/DigitalCurationCentre/DMPonline-Service/issues/679 Changes: - in app/controllers/super_admin/orgs_controller.rb added missing params to orgs_params method :funder, :institution, :organisation - in app/models/org.rb removed (as it is never set on Org creation) validates :abbreviation, presence: { message: PRESENCE_MESSAGE } - in app/views/orgs/_profile_form.html.erb removed :abbreviation required "aria-required": true - in app/views/shared/org_selectors/_external_only.html.erb renamed wrongly named text field :org_name to :name <%= form.label :name, label %> <%= form.text_field :name, class: "form-control autocomplete", --- app/controllers/super_admin/orgs_controller.rb | 3 ++- app/models/org.rb | 2 -- app/views/orgs/_profile_form.html.erb | 2 +- app/views/shared/org_selectors/_external_only.html.erb | 4 ++-- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/app/controllers/super_admin/orgs_controller.rb b/app/controllers/super_admin/orgs_controller.rb index a2cd2fe183..50ff0b421b 100644 --- a/app/controllers/super_admin/orgs_controller.rb +++ b/app/controllers/super_admin/orgs_controller.rb @@ -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 diff --git a/app/models/org.rb b/app/models/org.rb index 147f64348a..5a7466f6f7 100644 --- a/app/models/org.rb +++ b/app/models/org.rb @@ -94,8 +94,6 @@ class Org < ApplicationRecord validates :name, presence: { message: PRESENCE_MESSAGE }, uniqueness: { message: UNIQUENESS_MESSAGE } - validates :abbreviation, presence: { message: PRESENCE_MESSAGE } - validates :is_other, inclusion: { in: BOOLEAN_VALUES, message: PRESENCE_MESSAGE } diff --git a/app/views/orgs/_profile_form.html.erb b/app/views/orgs/_profile_form.html.erb index 15971d2c3c..5226143c6d 100644 --- a/app/views/orgs/_profile_form.html.erb +++ b/app/views/orgs/_profile_form.html.erb @@ -25,7 +25,7 @@
<%= f.label :abbreviation, _('Organisation abbreviated name'), class: "control-label" %> - <%= f.text_field :abbreviation, id: "org_abbreviation", class: "form-control", "aria-required": true %> + <%= f.text_field :abbreviation, id: "org_abbreviation", class: "form-control" %>
<% end %> diff --git a/app/views/shared/org_selectors/_external_only.html.erb b/app/views/shared/org_selectors/_external_only.html.erb index daf0ef3456..9353e1c05a 100644 --- a/app/views/shared/org_selectors/_external_only.html.erb +++ b/app/views/shared/org_selectors/_external_only.html.erb @@ -13,8 +13,8 @@ presenter = OrgSelectionPresenter.new(orgs: [default_org], placeholder = _("Begin typing to see a list of suggestions.") %> -<%= form.label :org_name, label %> -<%= form.text_field :org_name, class: "form-control autocomplete", +<%= form.label :name, label %> +<%= form.text_field :name, class: "form-control autocomplete", placeholder: placeholder, value: presenter.name, spellcheck: true, From 7e0f2e286bdc207ce17b44bec5b4138eef056fa7 Mon Sep 17 00:00:00 2001 From: Ray Carrick Date: Tue, 1 Feb 2022 10:59:36 +0000 Subject: [PATCH 3/7] debugging look at what comes out of safe_save --- spec/services/api/v1/persistence_service_spec.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/spec/services/api/v1/persistence_service_spec.rb b/spec/services/api/v1/persistence_service_spec.rb index d39b65c852..12e6ac47ad 100644 --- a/spec/services/api/v1/persistence_service_spec.rb +++ b/spec/services/api/v1/persistence_service_spec.rb @@ -43,6 +43,8 @@ plan.contributors << contributor plan.contributors << contributor2 result = described_class.safe_save(plan: plan) + pp "CONTRIBUTORS:" + pp result.contributors expect(result.contributors.length).to eql(2) expect(result.contributors.first.org).to eql(result.contributors.last.org) end From ce359956fbbc75c31010294e07668d01876a473b Mon Sep 17 00:00:00 2001 From: Ray Carrick Date: Tue, 1 Feb 2022 11:09:51 +0000 Subject: [PATCH 4/7] undo debug - now working Schrodinger's cat, it seems --- spec/services/api/v1/persistence_service_spec.rb | 2 -- 1 file changed, 2 deletions(-) diff --git a/spec/services/api/v1/persistence_service_spec.rb b/spec/services/api/v1/persistence_service_spec.rb index 12e6ac47ad..d39b65c852 100644 --- a/spec/services/api/v1/persistence_service_spec.rb +++ b/spec/services/api/v1/persistence_service_spec.rb @@ -43,8 +43,6 @@ plan.contributors << contributor plan.contributors << contributor2 result = described_class.safe_save(plan: plan) - pp "CONTRIBUTORS:" - pp result.contributors expect(result.contributors.length).to eql(2) expect(result.contributors.first.org).to eql(result.contributors.last.org) end From 60a88be6eb75cf96ffdb460deda685fdbc54ac0a Mon Sep 17 00:00:00 2001 From: Ray Carrick Date: Tue, 1 Feb 2022 11:31:56 +0000 Subject: [PATCH 5/7] debugging failure in org model spec --- spec/models/org_spec.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spec/models/org_spec.rb b/spec/models/org_spec.rb index 5e412f74d6..eb8622645a 100644 --- a/spec/models/org_spec.rb +++ b/spec/models/org_spec.rb @@ -11,7 +11,8 @@ is_expected.to validate_uniqueness_of(:name) .with_message('must be unique') } - + pp "ORG:" + pp subject it { is_expected.to validate_presence_of(:abbreviation) } it { is_expected.to allow_values(true, false).for(:is_other) } From 1be3a6047f4ac585809be14e2053a88802f64101 Mon Sep 17 00:00:00 2001 From: Ray Carrick Date: Tue, 1 Feb 2022 11:38:26 +0000 Subject: [PATCH 6/7] once more to debug org spec failing with no abbrev for some reason. --- spec/models/org_spec.rb | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/spec/models/org_spec.rb b/spec/models/org_spec.rb index eb8622645a..366b0d84eb 100644 --- a/spec/models/org_spec.rb +++ b/spec/models/org_spec.rb @@ -11,9 +11,12 @@ is_expected.to validate_uniqueness_of(:name) .with_message('must be unique') } - pp "ORG:" - pp subject - it { is_expected.to validate_presence_of(:abbreviation) } + + it "is expected to have an abbeviation" do + pp "ORG:" + pp subject + is_expected.to validate_presence_of(:abbreviation) + end it { is_expected.to allow_values(true, false).for(:is_other) } From e2c49142e7d8ffcbcf8ffb5cc9e63d1692b8a427 Mon Sep 17 00:00:00 2001 From: Ray Carrick Date: Tue, 1 Feb 2022 12:02:00 +0000 Subject: [PATCH 7/7] Remove prg has to have abbrev test Used to be that org had to have an abbrev. That stopped the Super Admin creating the org so was removed. Remove check from this test. --- spec/models/org_spec.rb | 6 ------ 1 file changed, 6 deletions(-) diff --git a/spec/models/org_spec.rb b/spec/models/org_spec.rb index 366b0d84eb..1fbe9c8e8f 100644 --- a/spec/models/org_spec.rb +++ b/spec/models/org_spec.rb @@ -12,12 +12,6 @@ .with_message('must be unique') } - it "is expected to have an abbeviation" do - pp "ORG:" - pp subject - is_expected.to validate_presence_of(:abbreviation) - end - it { is_expected.to allow_values(true, false).for(:is_other) } it { is_expected.not_to allow_value(nil).for(:is_other) }