From 8fd7fcb64c1ace87d13c971737d26f17f5531fa3 Mon Sep 17 00:00:00 2001 From: viliambalaz Date: Sat, 23 Jan 2021 16:35:54 +0100 Subject: [PATCH] #342 Use transaction.atomic --- .../commands/attachment_anonymization.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/chcemvediet/apps/anonymization/management/commands/attachment_anonymization.py b/chcemvediet/apps/anonymization/management/commands/attachment_anonymization.py index 1e28ba3dd..158f5ce77 100644 --- a/chcemvediet/apps/anonymization/management/commands/attachment_anonymization.py +++ b/chcemvediet/apps/anonymization/management/commands/attachment_anonymization.py @@ -71,12 +71,11 @@ def handle(self, *args, **options): if not content: raise CommandError(u'No content given.') - with transaction.atomic(): - attachments_finalization.delete() - AttachmentFinalization.objects.create( - attachment=attachment, - successful=True, - file=ContentFile(content), - content_type=options[u'content_type'] or magic.from_buffer(content, mime=True), - debug=options[u'debug'], - ) + attachments_finalization.delete() + AttachmentFinalization.objects.create( + attachment=attachment, + successful=True, + file=ContentFile(content), + content_type=options[u'content_type'] or magic.from_buffer(content, mime=True), + debug=options[u'debug'], + )