-
-
Notifications
You must be signed in to change notification settings - Fork 571
Enable csv import of partners with six fields #5171
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
2601e4c to
25b655e
Compare
cielf
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for taking this on -- here's your Functional review, pass one. Mentioning @dorner re your above request for advice.
Review notes:
1/ I'd like to see a warning if the default storage location indicated does not exist as a storage location on the organization -- I think uploading, but with a warning would be the case of least surprise here.
2/ I left the send_reminders blank on a partner. I expected that to give a false send_reminders, but instead the partner failed to upload, with no explanation.
3/ I then added a few more items to the upload file, including blank default storage partner. I got an "ActiveModel::UnknownAttributeError at /partners/import_csv.
unknown attribute 'default_storage_location' for Partner." error on the blank one. If there is no default storage location indicated, the partner should be uploadable - we just don't set it.
4/ I like the case insensitive matching on the storage locations!
|
@McEileen when you say you couldn't get it working... what did you try, and what problems did you see? |
|
@dorner Good question. My initial approach was to search for the default storage location using the name that the user entered, and to then throw an error if To give a code example, if I change the It causes 39 tests to fail. 😓 |
|
@cielf Thank you for the thorough functional review! 1/ I'll work on this and reach out with any follow-up questions. 2/ Did the test csv file you upload have the Or was it missing both the 3/ Same question here. When there's a blank default storage partner, does that mean the header is present and the field is missing, as seen below? Or does it mean both the default_storage_location header and field are missing, as seen below? |
|
@McEileen -- 2/ I think it had the header, but for that row, it had no value. I was working with numbers and exporting... so it was showing blank rather than FALSE. Which should have produced something like If that doesn't work, let me know and I'll reproduce an example. 3/ Similarly for this one should do the trick |
88b9351 to
c49ff72
Compare
cielf
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm down to 1 quibble, functionally:
If we have a partner with a misspelled storage location name, can we get that to appear as a warning rather than an error? (ie show it as black on yellow, rather than the white on red).
Otherwise looks very good!
@cielf Sure, I'll look into that this weekend. |
c49ff72 to
402bf79
Compare
McEileen
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @cielf, I made the warning change that you requested. Let me know what you think! (I am a little uneasy about how it required me to make changes to other models that also use the importable concern, however, I was able to get #import_csv tests passing.)
app/models/partner.rb
Outdated
| if svc.errors.present? | ||
| if svc.errors.present? && svc.partner.errors.blank? | ||
| warnings << "#{svc.partner.name}: #{svc.errors.full_messages.to_sentence}" | ||
| elsif svc.errors.present? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cielf I wanted to highlight this logic to you.
If a user attempts to upload a partner with an email and name that is already in use, in addition to a misspelled storage location name, both the email/name messages and the storage location message will display as errors. If you want, I could look into displaying the email/name error messages as errors and the storage location message as a warning. Let me know what you prefer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My initial take is that if the partner is not getting added, having everything as errors won't be a big deal.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For that matter -- if it's easier, it would be ok if it just showed the errors in that case, without the warning?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @cielf, thanks for flagging this. I realize what I said in this comment was incorrect, apologies.
I pushed up another commit to make my previous commit actually accurate. If you want, I could also stick with the version where if both errors and warnings occur, only errors display. Let me know what you prefer!
398c481 to
176d88a
Compare
|
Hey @McEileen - I ran the attached csv, and it mostly looks good. However, the warnings aren't showing up. (I suspect you're only showing the warnings if there are no errors, but I haven't confirmed that.) partners_import_test_20250602.csv Results in: |
dad84ac to
c953b42
Compare
|
Hey @McEileen -- don't know if this is supposed to be ready for review, but partner 9 in the earlier attached csv should show a warning, and isn't. |
|
Hey @McEileen -- are you still working on this? |
|
Hi, I apologize for being out of touch. As I shared with greater detail in slack, I won't be able to contribute to Human Essentials for the next couple of months. Anyone who is interested is willing to work on the linked issue, #5056, and is also welcome to build off the code in this PR. |
- Fix specs associated with CSV import
c953b42 to
5844569
Compare
|
@cielf This has been updated to display the warnings. Using partners_import_test_20250602.csv locally shows the errors/warnings as below:
|
|
Hrm. I'm seeing different results. If I then check with org_admin1@example.com, I get: (Edit) |
|
Some thoughts on the situation above: 1/ I suspect that org_admin2@example.com doesn't have a default storage location set, whereas org_admin1@example.com might. 2/ That we didn't get any errors on importing as org_admin1@example.com after importing the same partners as org_admin2@example.com seems more than a little odd -- it also only imported one of the partners. I'm going to point out that the partner that it did import would have failed, after a successful import of an earlier one. I feel like there's something going on here around checking partner names / emails across the system rather than within the bank. |
|
But/and this raises bigger questions. (IIRC, we do not currently allow partners to send requests to multiple banks) so I'm ccing in @awwaiid. |
|
Also ccing in @ruestitch |
| if params[:file].present? | ||
| data = File.read(params[:file].path, encoding: "BOM|UTF-8") | ||
| csv = CSV.parse(data, headers: true) | ||
| csv = CSV.parse(data, headers: true, skip_blanks: true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For consistence, do we actually want to add skip_blanks: true when we have a number of other places where we parse CSV data where we don't? It's easier to explain a rule on import to users that's true in all cases.
If we think we should allow+skip blanks on CSV import, can we leave that out here and do it in a separate PR updating every CSV.parse we're using?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 consistency is good, I removed that change
|
Automatically unassigned after 7 days of inactivity. |
|
Note @ParsannaK is working on #5056 -- Not clear whether they are extending this PR -- so keep a look out for a PR from them instead. |




Resolves #5056
Description
/partnersand click "Import partners"name,email,default_storage_location,send_reminders,quota,notesdefault_storage_idcolumn.Type of change
How Has This Been Tested?