+ def build_cover(self, book_info=None):
+ """(Re)builds the cover image."""
+ from StringIO import StringIO
+ from django.core.files.base import ContentFile
+ from librarian.cover import WLCover
+
+ if book_info is None:
+ book_info = self.wldocument().book_info
+
+ cover = WLCover(book_info).image()
+ imgstr = StringIO()
+ cover.save(imgstr, 'png')
+ self.cover.save(None, ContentFile(imgstr.getvalue()))
+