rcpch / national-paediatric-diabetes-audit

A django application to audit the care of children and young people with diabetes in England and Wales.
0 stars 1 forks source link

Don't crash on unhandled errors saving patient and visit in CSV upload #346

Closed mbarton closed 3 weeks ago

mbarton commented 3 weeks ago

Fixes #345 Fixes #331

Prior to this PR we just read form.errors_as_data to get a list of ValidationError instances per field for Patient and Visit. Unfortunately this strategy fell down for errors that later on cause the model to save, for example removing the year portion of the date only leaving the day and month.

This PR simplifies and extends error handling to grab all errors that occur saving patient and visit, combine them with the form validation errors and return them.

We no longer need to check if a form validation error will cause a knock on failure to save, as we'll just catch that later anyway.

For the moment we just toast each error which is quite horrible but at least gives the user ALL the information:

Capture

I've also moved the toast to the bottom of the template so they appear over the top of the rest of the page correctly.

mbarton commented 3 weeks ago

Seen on STAGING (merged by @mbarton 5 minutes and 24 seconds ago) Please check your changes!