Skip to content

DRAFT PR: Added feature "Org admins can show/hide the ethical_issues field on p…#3578

Closed
johnpinto1 wants to merge 1 commit into
mainfrom
issue/3555
Closed

DRAFT PR: Added feature "Org admins can show/hide the ethical_issues field on p…#3578
johnpinto1 wants to merge 1 commit into
mainfrom
issue/3555

Conversation

@johnpinto1

@johnpinto1 johnpinto1 commented Oct 17, 2025

Copy link
Copy Markdown
Contributor

…lans" #3555
Changes:

(1) Added a property Rails.configuration.x.madmp.enable_ethical_issues_per_template to configuration which works as follows: If Rails.configuration.x.madmp.enable_ethical_issues is true, this flag hide_ethical_issues_question_per_template comes into play. It will determine if the ethical_issues question is hidden/shown based on the template selected for the plan. If the template has the hide_ethical_issues attribute set to true, then the question will be hidden. If the template has the hide_ethical_issues is set to false, then the question will be shown.

(2) Added to Template model
attribute :hide_ethical_issues_question, :boolean, default: false
with migration.

(3) Added a safe param :hide_ethical_issues_question to the org admin Template controller.

(4) Updated the app/views/org_admin/templates/_form.html.erb to display a checkbox for "Hide question about ethical issues". This checkbox will only appear if Rails.configuration.x.madmp.enable_ethical_issues and Rails.configuration.x.madmp.enable_ethical_issues_per_template are both set to true in config.

(5) Updated the conitional for display of the ethical issues question in the Project details page as follows:
<% if Rails.configuration.x.madmp.enable_ethical_issues &&
(!Rails.configuration.x.madmp.enable_hide_ethical_issues_per_template ||
(Rails.configuration.x.madmp.enable_hide_ethical_issues_per_template && plan.template.present? && plan.template.hide_ethical_issues_question.present? && !plan.template.hide_ethical_issues_question)) %>

Comment thread db/schema.rb Outdated
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"

create_table "admin_users", id: :serial, force: :cascade do |t|

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There seems to be a lot of unintended changes being made to the DB schema here. Could a different DB have been used when the migration was made?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@momo3404 Thanks for spotting that. I will remove the schema.rb from commit.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@momo3404 I have removed the schema.rb from commit as suggested.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@momo3404 I think I need to load schema.rb again without the unnecessary change to fix test on Github.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@momo3404 After a bit of a struggle I managed to create schema.rb with only the current migration change.
After restoring old db/schema.rb
git co db/schema.rb
rails db:schema:load
rails db:migrate VERSION=20251016134521

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test failing for another reason now.

@johnpinto1 johnpinto1 force-pushed the issue/3555 branch 4 times, most recently from 9202464 to f854090 Compare October 20, 2025 09:55
…plans" (#3555).

    Changes:

    (1) Added a property Rails.configuration.x.madmp.enable_ethical_issues_per_template to configuration which works as follows:
    If Rails.configuration.x.madmp.enable_ethical_issues is true, this flag hide_ethical_issues_question_per_template comes into play.
    It will determine if the ethical_issues question is hidden/shown based on the template selected for the plan.
    If the template has the hide_ethical_issues attribute set to true, then the question will be hidden.
    If the template has the hide_ethical_issues is set to false, then the question will be shown.

    (2) Added to Template model
        attribute :hide_ethical_issues_question, :boolean, default: false
    with migration.

    (3) Added a safe param :hide_ethical_issues_question to the org admin
    Template controller.

    (4) Updated the app/views/org_admin/templates/_form.html.erb to display a
    checkbox for "Hide question about ethical issues". This checkbox will
    only appear if Rails.configuration.x.madmp.enable_ethical_issues and
    Rails.configuration.x.madmp.enable_ethical_issues_per_template are both
    set to true in config.

    (5) Updated the conitional for display of the ethical issues question in
    the Project details page as follows:
    <% if Rails.configuration.x.madmp.enable_ethical_issues &&
          (!Rails.configuration.x.madmp.enable_hide_ethical_issues_per_template  ||
           (Rails.configuration.x.madmp.enable_hide_ethical_issues_per_template  && plan.template.present? && plan.template.hide_ethical_issues_question.present? && !plan.template.hide_ethical_issues_question)) %>
@johnpinto1

Copy link
Copy Markdown
Contributor Author

Withdrawing PR, as there was some misunderstanding on my part on the requirements that DCC implemented.

@johnpinto1 johnpinto1 closed this Oct 20, 2025
@johnpinto1

Copy link
Copy Markdown
Contributor Author

Thanks @aaronskiba and @momo3404 for comments and advice.

@johnpinto1 johnpinto1 deleted the issue/3555 branch October 21, 2025 15:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants