Skip to content

[DRAFT] Enable ROR-Based Org Creation for Funders#1262

Draft
momo3404 wants to merge 10 commits intomomo/issues/926-editfrom
momo/issues/funders-draft
Draft

[DRAFT] Enable ROR-Based Org Creation for Funders#1262
momo3404 wants to merge 10 commits intomomo/issues/926-editfrom
momo/issues/funders-draft

Conversation

@momo3404
Copy link
Collaborator

@momo3404 momo3404 commented Jan 21, 2026

Changes proposed in this PR:

  • Change the funder selection field in a plan from a text field to a dropdown that includes orgs in the DMP Assistant DB and external orgs validated by ROR.
  • Funder attributes are set in the update function of the PlansController, so the following changes are made there:
    - Set funder id in the plan only if a funder is available.
    - Add the invalid_funder? helper function, which returns true when a funder organization is entered and is invalid (does not have a valid ROR or exist in the local DB).
    - Edit the failure message to include 'Invalid funder' when an invalid funder is entered.
  • These changes will prevent the creation of junk orgs from the funder tab, as any funder organization that is entered must have a valid ROR.

- Remove org_id setting since it was incorrectly setting org_id
@github-actions
Copy link

github-actions bot commented Jan 21, 2026

1 Error
🚫 Please include a CHANGELOG entry. You can find it at CHANGELOG.md.
1 Warning
⚠️ There are code changes, but no corresponding tests. Please include tests if this PR introduces any modifications in behavior. \n
Ignore this warning if the PR ONLY contains translation.io synced updates.

Generated by 🚫 Danger

Copy link
Collaborator

@aaronskiba aaronskiba left a comment

Choose a reason for hiding this comment

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

I tried updating an existing plan without touching the funder field. The update seems to have saved successfully, but I got the following error:
Screenshot from 2026-01-21 14-39-14

Copy link
Collaborator

@aaronskiba aaronskiba left a comment

Choose a reason for hiding this comment

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

I'm not sure why an org dropdown was never implemented for plan.funder selection. Maybe this would be the right time to do it? Since we are limiting the options to db + ROR orgs, rendering the org names like we are for the contributor affiliation could really help user experience here.

@momo3404 momo3404 marked this pull request as draft January 22, 2026 17:12
@aaronskiba
Copy link
Collaborator

I'm not sure why an org dropdown was never implemented for plan.funder selection. Maybe this would be the right time to do it? Since we are limiting the options to db + ROR orgs, rendering the org names like we are for the contributor affiliation could really help user experience here.

My bad, I just had to precompile the assets. That's awesome that switching to the combined partial adds the dropdown.

@aaronskiba
Copy link
Collaborator

Maybe just update the description explaining why these changes are necessary in the controller action.

# PUT /plans/1
# rubocop:disable Metrics/MethodLength, Metrics/PerceivedComplexity
def update
def update # rubocop:disable Metrics/CyclomaticComplexity
Copy link
Collaborator

Choose a reason for hiding this comment

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

This update action is already a bit of a monster. Maybe a private helper for the new funder assignment logic will at least prevent the new CyclomaticComplexity offense.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I added a helper for the funder assignment logic, but that doesn't seem to remove the error. It looks like that was added due to adding !invalid_funder to this line if @plan.update(attrs) && !invalid_funder.

Copy link
Collaborator

@aaronskiba aaronskiba left a comment

Choose a reason for hiding this comment

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

Screenshot from 2026-01-21 14-39-14

The above flash message is sometimes rendered even when the plan is in fact saved. For example, I updated a few fields within the "Project Details" tab and added an invalid funder. The other fields were saved, but that flash message was still rendered.

There's another behaviour that may be worth addressing too; what to do when the plan.funder field has a valid entry saved and then the user attempts to save an invalid funder. Currently, when this happens, plan.funder is saved with an empty value. I think it would be better to preserve the previous valid entry in this case.

@momo3404
Copy link
Collaborator Author

The above flash message is sometimes rendered even when the plan is in fact saved. For example, I updated a few fields within the "Project Details" tab and added an invalid funder. The other fields were saved, but that flash message was still rendered.

There's another behaviour that may be worth addressing too; what to do when the plan.funder field has a valid entry saved and then the user attempts to save an invalid funder. Currently, when this happens, plan.funder is saved with an empty value. I think it would be better to preserve the previous valid entry in this case.

I just pushed a commit that changes the message to just "Invalid funder" when the funder fails to save, and I edited the funder id assignment to only occur when the field is cleared or there's a valid funder.

- Change handling to check for if plan updated first, then append invalid funder accordingly
- Simplify some of the code for failure messages and alerts
attrs = remove_org_selection_params(params_in: attrs)

if @plan.update(attrs) # _attributes(attrs)
if @plan.update(attrs)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I kinda worry about how many lines of code are being changed for this flash message handling.

I wonder if most of this could be reverted and we could simply have something like the following:

if @plan.update(attrs)
  notice = success_message(@plan, _('saved'))
  notice += _(" The funder was not updated because it is invalid") unless valid_funder
(... previous code)

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