from cover.utils import get_import_data
-PREVIEW_SIZE = (216, 300)
+PREVIEW_SIZE = (212, 300)
def preview(request, book, chunk=None, rev=None):
If chunk and rev number are given, use version from given revision.
If rev is not given, use publishable version.
"""
- chunk = Chunk.get(book, chunk)
+ try:
+ chunk = Chunk.get(book, chunk)
+ except Chunk.DoesNotExist:
+ raise Http404
+
+ if chunk.book.cover and rev is None and not request.GET.get('width') and not request.GET.get('height'):
+ return HttpResponseRedirect(chunk.book.cover.url)
+
if rev is not None:
try:
revision = chunk.at_revision(rev)