From 929b6613f0d78c98a28613932425d195c8a8698e Mon Sep 17 00:00:00 2001 From: John Pinto Date: Wed, 22 Oct 2025 12:55:36 +0100 Subject: [PATCH 1/3] Issue #3555 - Added feature for Org admins can show/hide the Ethical_Issues fragment in plans project details page. Co-authored-by: don-stuckey This feature was contributed to DMPonline by @don-stuckey. Changes: - These changes only kick in if enable_ethical_issues is enable in the application config. - Added to Org model attribute in a migration add_ro_ethical_concerns :boolean default(true), not null - Added a checkbox 'Add "Research outputs may have ethical concerns" field to "Project details" tab in plans' to app/views/orgs/_profile_form.html.erb. - Added code to the Plan Project Details view to show or hide the Ethical Issues fragment. - Added :add_ro_ethical_concerns to the strong params org_params for the Org controller. --- CHANGELOG.md | 2 ++ app/controllers/orgs_controller.rb | 1 + app/models/org.rb | 1 + app/views/orgs/_profile_form.html.erb | 30 +++++++++++++++++++ app/views/plans/_project_details.html.erb | 12 +++++++- ...759_add_add_ro_ethical_concerns_to_orgs.rb | 6 ++++ db/schema.rb | 3 +- 7 files changed, 53 insertions(+), 2 deletions(-) create mode 100644 db/migrate/20250829093759_add_add_ro_ethical_concerns_to_orgs.rb diff --git a/CHANGELOG.md b/CHANGELOG.md index b5637083df..0d97e39bfc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ # Changelog +- Feature for Org admins can show/hide the ethical_issues field on plans [#3555](https://github.com/DMPRoadmap/roadmap/pull/3555). + ## v5.0.2 - Bump Ruby to v3.1.4 and use `.ruby-version` in CI - [#3566](https://github.com/DMPRoadmap/roadmap/pull/3566) diff --git a/app/controllers/orgs_controller.rb b/app/controllers/orgs_controller.rb index ed0e3f78df..256bf4c43b 100644 --- a/app/controllers/orgs_controller.rb +++ b/app/controllers/orgs_controller.rb @@ -222,6 +222,7 @@ def org_params .permit(:name, :abbreviation, :logo, :contact_email, :contact_name, :remove_logo, :managed, :feedback_enabled, :org_links, :funder, :institution, :organisation, + :add_ro_ethical_concerns, :feedback_msg, :org_id, :org_name, :org_crosswalk, :helpdesk_email, identifiers_attributes: %i[identifier_scheme_id value], diff --git a/app/models/org.rb b/app/models/org.rb index 6a6eac55d2..4b96bdf6af 100644 --- a/app/models/org.rb +++ b/app/models/org.rb @@ -25,6 +25,7 @@ # region_id :integer # managed :boolean default(false), not null # helpdesk_email :string +# add_ro_ethical_concerns :boolean default(true), not null # # Foreign Keys # diff --git a/app/views/orgs/_profile_form.html.erb b/app/views/orgs/_profile_form.html.erb index ade41ce1cf..e292fafb5b 100644 --- a/app/views/orgs/_profile_form.html.erb +++ b/app/views/orgs/_profile_form.html.erb @@ -180,7 +180,37 @@ <% end %> +
+ <%# Organisation Permissions block where super admin can add: + "Project details" tab in a plan + %> + + <% org_perms_header_block = capture do %> +

+ <%= _('Organisation Permissions') %> +

+ <% end %> + + <% add_ro_ethical_concerns_block = capture do %> +
+ <%= f.label :add_ro_ethical_concerns do %> + <%= f.check_box :add_ro_ethical_concerns, { class: 'org_types', value: org.add_ro_ethical_concerns? }, "true", "false" %> + <%= _('Add "Research outputs may have ethical concerns" field to "Project details" tab in plans') %> + <% end %> +
+ <% end %> +
+ <% if current_user.can_super_admin? %> +
+ <%= org_perms_header_block %> + <%= add_ro_ethical_concerns_block %> +
+ <% elsif current_user.can_org_admin? %> + <%= org_perms_header_block %> + <%= add_ro_ethical_concerns_block %> + <% end %> +

<% if !org.new_record? %> diff --git a/app/views/plans/_project_details.html.erb b/app/views/plans/_project_details.html.erb index 48eada3e92..ef8299e9da 100644 --- a/app/views/plans/_project_details.html.erb +++ b/app/views/plans/_project_details.html.erb @@ -102,7 +102,7 @@ ethics_report_tooltip = _("Link to a protocol from a meeting with an ethics comm <% end %> -<% if Rails.configuration.x.madmp.enable_ethical_issues %> +<% ethical_issues_block = capture do %>
@@ -143,6 +143,16 @@ ethics_report_tooltip = _("Link to a protocol from a meeting with an ethics comm <% end %> +<% if Rails.configuration.x.madmp.enable_ethical_issues %> + <% if plan.ethical_issues == true %> + <%= ethical_issues_block %> + <% else %> + <% if current_user.org.add_ro_ethical_concerns? %> + <%= ethical_issues_block %> + <% end %> + <% end %> +<% end %> +
diff --git a/db/migrate/20250829093759_add_add_ro_ethical_concerns_to_orgs.rb b/db/migrate/20250829093759_add_add_ro_ethical_concerns_to_orgs.rb new file mode 100644 index 0000000000..bcc35469db --- /dev/null +++ b/db/migrate/20250829093759_add_add_ro_ethical_concerns_to_orgs.rb @@ -0,0 +1,6 @@ +class AddAddRoEthicalConcernsToOrgs < ActiveRecord::Migration[6.1] + def change + add_column :orgs, :add_ro_ethical_concerns, :boolean, default: true, null: false + Org.update_all(add_ro_ethical_concerns: true) + end +end \ No newline at end of file diff --git a/db/schema.rb b/db/schema.rb index 3b6036f2bf..7c61d2214f 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.1].define(version: 2025_01_15_102816) do +ActiveRecord::Schema[7.1].define(version: 2025_10_16_134521) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -276,6 +276,7 @@ t.string "api_create_plan_email_subject" t.text "api_create_plan_email_body" t.string "helpdesk_email" + t.boolean "add_ro_ethical_concerns", default: true, null: false t.index ["language_id"], name: "fk_rails_5640112cab" t.index ["region_id"], name: "fk_rails_5a6adf6bab" end From bdbfefa55a478c6b121edc0869c71e43a05c0d1d Mon Sep 17 00:00:00 2001 From: John Pinto Date: Mon, 27 Oct 2025 10:12:50 +0000 Subject: [PATCH 2/3] Updated migration add_add_ro_ethical_concerns_to_orgs for Rails version 7.1. --- ... => 20251027100520_add_add_ro_ethical_concerns_to_orgs.rb} | 4 ++-- db/schema.rb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) rename db/migrate/{20250829093759_add_add_ro_ethical_concerns_to_orgs.rb => 20251027100520_add_add_ro_ethical_concerns_to_orgs.rb} (69%) diff --git a/db/migrate/20250829093759_add_add_ro_ethical_concerns_to_orgs.rb b/db/migrate/20251027100520_add_add_ro_ethical_concerns_to_orgs.rb similarity index 69% rename from db/migrate/20250829093759_add_add_ro_ethical_concerns_to_orgs.rb rename to db/migrate/20251027100520_add_add_ro_ethical_concerns_to_orgs.rb index bcc35469db..424e1c021e 100644 --- a/db/migrate/20250829093759_add_add_ro_ethical_concerns_to_orgs.rb +++ b/db/migrate/20251027100520_add_add_ro_ethical_concerns_to_orgs.rb @@ -1,6 +1,6 @@ -class AddAddRoEthicalConcernsToOrgs < ActiveRecord::Migration[6.1] +class AddAddRoEthicalConcernsToOrgs < ActiveRecord::Migration[7.1] def change add_column :orgs, :add_ro_ethical_concerns, :boolean, default: true, null: false Org.update_all(add_ro_ethical_concerns: true) end -end \ No newline at end of file +end diff --git a/db/schema.rb b/db/schema.rb index 7c61d2214f..2aecbdbe93 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.1].define(version: 2025_10_16_134521) do +ActiveRecord::Schema[7.1].define(version: 2025_10_27_100520) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" From af7d615902b7d8c31463a771b13669f46566f0fd Mon Sep 17 00:00:00 2001 From: John Pinto Date: Tue, 28 Oct 2025 10:04:30 +0000 Subject: [PATCH 3/3] Refactored code for the Ethical Concerns block suggested during PR review. --- app/views/orgs/_profile_form.html.erb | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/app/views/orgs/_profile_form.html.erb b/app/views/orgs/_profile_form.html.erb index e292fafb5b..abb6df5d7c 100644 --- a/app/views/orgs/_profile_form.html.erb +++ b/app/views/orgs/_profile_form.html.erb @@ -200,18 +200,15 @@
<% end %> -
- <% if current_user.can_super_admin? %> + <% if current_user.can_org_admin? %> +
<%= org_perms_header_block %> <%= add_ro_ethical_concerns_block %>
- <% elsif current_user.can_org_admin? %> - <%= org_perms_header_block %> - <%= add_ro_ethical_concerns_block %> - <% end %> -
-
+
+
+ <% end %> <% if !org.new_record? %> <%= render partial: "orgs/external_identifiers",