From 490d9769077b3e0a9e9c5055d050bc9fb93c0df7 Mon Sep 17 00:00:00 2001 From: Guillaume Pellerin Date: Thu, 25 Apr 2024 11:32:41 +0200 Subject: [PATCH] manage multiple private doc --- teleforma/models/core.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/teleforma/models/core.py b/teleforma/models/core.py index 1cf1096d..87564214 100644 --- a/teleforma/models/core.py +++ b/teleforma/models/core.py @@ -853,7 +853,11 @@ class Document(MediaBase): super(Document, self).save(**kwargs) def private_file(self, user): - private_document, c = DocumentPrivate.objects.get_or_create(document=self, user=user) + try: + private_document, c = DocumentPrivate.objects.get_or_create(document=self, user=user) + except: + private_documents = DocumentPrivate.objects.filter(document=self, user=user) + private_document = private_documents[0] return private_document.file -- 2.39.5