]> git.parisson.com Git - teleforma.git/commitdiff
manage multiple private doc
authorGuillaume Pellerin <guillaume.pellerin@free.fr>
Thu, 25 Apr 2024 09:32:41 +0000 (11:32 +0200)
committerGuillaume Pellerin <guillaume.pellerin@free.fr>
Thu, 25 Apr 2024 09:32:41 +0000 (11:32 +0200)
teleforma/models/core.py

index 1cf1096df802fc0afe17dc9204c67d85bd68da3b..8756421488e1ecce56e7ce3115727a7c6049d24b 100644 (file)
@@ -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