keep-the-receipts / procurement-portal-backend

Backend for a portal for searching procurement records
MIT License
0 stars 3 forks source link

make all dataset upload errors visible to admins #45

Closed jbothma closed 4 years ago

jbothma commented 4 years ago

As a data admin, I would like to know whether uploads were successful so that I can tell whether it is complete or whether I need to change something and try again.

Options for satisfying that

e.g.

Admin error feedback: tablib.exceptions.InvalidDimensions

e.g.

django.core.exceptions.ValidationError: ['Missing field(s): buyer_name, supplier_name, order_amount_zar']
jbothma commented 4 years ago

django-import-export errors as well

Basically we have a model Dataset with a field current_version foreign key to DatasetVersion and DatasetVersion has a foreign key to Dataset and a file field.

The idea is that a dataset can have multiple versions - each file is associated with a DatasetVersion.

When a dataset is created, the admin should also upload a file as the initial DatasetVersion. This is currently done using an inline on the dataset admin, but there's also a datasetversion admin (which is less convenient because you have to select from a growing list of datasets with imprecise names, and it's a separate page from where the dataset is created so it's easy to forget)

Every time a new DatasetVersion is uploaded (e.g. to fix a mistake or improve the dataset somehow), the new file needs to be imported (we use django-import-export via its API rather than its admin integration). This is currently done using a signal, which is not ideal because it doesn't have access to the request to provide error feedback. https://github.com/keep-the-receipts/procurement-portal-backend/pull/44 had to be reverted because it wasn't working from the dataset admin and was silently allowing dataset versions to be created despite importing failing.

Creating a new version should set it as the current version.

Editing a random version should not set it as the latest version, since you might simply be fixing metadata on an old version.

jbothma commented 4 years ago

https://stackoverflow.com/a/31431103

jbothma commented 4 years ago

fixed by https://github.com/keep-the-receipts/procurement-portal-backend/pull/50