human-essentials icon indicating copy to clipboard operation
human-essentials copied to clipboard

Display errors taking place during import partner process

Open jp524 opened this issue 4 months ago • 2 comments

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 success

Import with errors import errors

jp524 avatar Oct 05 '24 21:10 jp524