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 Document
instances.
This means several low-level changes:
- an
OcrModel
would then be usable across multiple documents - a document would still be usable across multiple
OcrModel
instance - the
OcrModel.owner
user 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 OcrModel
and Document
alongside a created
date (it's easier to do that from the beginning than a later migration to add it).
The OcrModelDocument
model would also store boolean states descritbing the interactions between an OcrModel
and a Document
:
-
trained_on
would be used when the model has been trained on the document -
executed_on
would be used when the model has been executed on the document to produce results
A unique constraing on document_id
and 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
- API
OcrModelViewSet
and 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.