X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/5913c54d19b8f6775633176032161d49f9b2f1aa..864d45abe5ec985836baf52de168943d25a03be6:/src/catalogue/management/__init__.py diff --git a/src/catalogue/management/__init__.py b/src/catalogue/management/__init__.py index bc3d6c02..e537f9e5 100644 --- a/src/catalogue/management/__init__.py +++ b/src/catalogue/management/__init__.py @@ -100,19 +100,15 @@ class XmlUpdater(object): books = Book.objects.all() # Start transaction management. - transaction.enter_transaction_management() - - for book in books: - self.counters['All books'] += 1 - chunks = book.chunk_set.all() - if self.only_first_chunk: - chunks = chunks[:1] - for chunk in chunks: - self.counters['All chunks'] += 1 - self.fix_chunk(chunk, user, verbose, dry_run) - - transaction.commit() - transaction.leave_transaction_management() + with transaction.atomic(): + for book in books: + self.counters['All books'] += 1 + chunks = book.chunk_set.all() + if self.only_first_chunk: + chunks = chunks[:1] + for chunk in chunks: + self.counters['All chunks'] += 1 + self.fix_chunk(chunk, user, verbose, dry_run) def print_results(self): """Prints the counters."""