Use a Many-to-Many relation between Document and OCRModel
The goal is to convert the
OcrModel.document Foreign Key to an
OcrModel.documents Many-to-Many relation towards
This means several low-level changes:
OcrModelwould then be usable across multiple documents
- a document would still be usable across multiple
OcrModel.owneruser would be the administrator of the model, no access rights could be easily extracted/aggregated from documents
A M2M "through" model named
OcrModelDocument would be created, only to store the relationship between
Document alongside a
created date (it's easier to do that from the beginning than a later migration to add it).
OcrModelDocument model would also store boolean states descritbing the interactions between an
OcrModel and a
trained_onwould be used when the model has been trained on the document
executed_onwould be used when the model has been executed on the document to produce results
A unique constraing on
model_id would ensure than only one M2M relation is possible between a model and a document.
This kind of changes can break a lot of functionalities in small ways, so we would need to fix the behaviour of (at least) these parts:
- document creation interface
- training tasks
- access control to models and documents
OcrModelViewSetand its usage
At this stage, we only update the database and surrounding code, reproducing current behaviour. The resulting code should be mergeable as-is and serve as basis for features development.