(backend) add creator field on document and allow filtering on it

We want to be able to limit the documents displayed on a logged-in user's
list view by the documents they created or by the documents that other
users created.

This is different from having the "owner" role on a document because this
can be acquired and even lost. What we want here is to be able to
identify documents by the user who created them so we add a new field.
This commit is contained in:
Samuel Paccoud - DINUM
2024-11-12 16:28:34 +01:00
committed by Anthony LC
parent 1899cff572
commit 23f90156bf
13 changed files with 453 additions and 68 deletions

View File

@@ -341,6 +341,9 @@ class Document(BaseModel):
link_role = models.CharField(
max_length=20, choices=LinkRoleChoices.choices, default=LinkRoleChoices.READER
)
creator = models.ForeignKey(
User, on_delete=models.RESTRICT, related_name="documents_created"
)
_content = None