Add transaction handling in more places

Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
This commit is contained in:
Roberto Rosario
2019-04-29 14:03:38 -04:00
parent 66d5016407
commit fda0dd4eaf
7 changed files with 102 additions and 82 deletions

View File

@@ -250,9 +250,12 @@ class DocumentVersion(models.Model):
self.document, self
)
event_document_version_revert.commit(actor=_user, target=self.document)
for version in self.document.versions.filter(timestamp__gt=self.timestamp):
version.delete()
with transaction.atomic():
event_document_version_revert.commit(
actor=_user, target=self.document
)
for version in self.document.versions.filter(timestamp__gt=self.timestamp):
version.delete()
def save(self, *args, **kwargs):
"""