Display errors taking place during import partner process
Resolves #4688
Description
In order to display a message when a partner import is failing I modified the existing Importable concern and the Partner model import_csv method. This ensures that any validation error (invalid email, name already taken, etc.) gets passed along to be displayed.
The message shown to the user is more specific than the one asked in the issue, but I think it makes sense to display the exact error to the user in order for them to easily fix it.
On a technical note: I chose to modify all import_csv methods to return nil if there's no error, or otherwise return an errors array. I'm open to suggestions if there's a better way to do this.
Type of change
- Bug fix (non-breaking change which fixes an issue)
How Has This Been Tested?
Added some requests tests for Partners, and ensured that tests for other models using import_csv (DonationSites, StorageLocation, ProductDriveParticipants, Vendors) were still passing.
Screenshots
Successful import
Import with errors
A quick thing I notice from your screenshot is that the errors are being displayed as a notice. Please display them as an error instead.
Thanks for catching that @cielf! It's been changed:
Passing to @dorner for technical review.
All good, thanks!
@jp524: Your PR Display errors taking place during import partner process is part of today's Human Essentials production release: 2024.10.27.
Thank you very much for your contribution!