+ @transaction.commit_on_success
+ def prepend_history(self, other):
+ """Prepend history from all the other book's chunks to own."""
+ assert self != other
+
+ for i in range(len(self), len(other)):
+ title = u"pusta część %d" % i
+ chunk = self.add(slughifi(title), title)
+ chunk.commit('')
+
+ for i in range(len(other)):
+ self[i].prepend_history(other[0])
+
+ assert not other.chunk_set.exists()
+ other.delete()
+
+ def split(self):
+ """Splits all the chunks into separate books."""
+ self.title
+ for chunk in self:
+ book = Book.objects.create(title=chunk.title, slug=chunk.slug,
+ public=self.public, gallery=self.gallery)
+ book[0].delete()
+ chunk.book = book
+ chunk.number = 1
+ chunk.save()
+ assert not self.chunk_set.exists()
+ self.delete()
+