tag.count = theme_counter[tag.pk]
extra_info = book.get_extra_info_value()
+ hide_about = extra_info.get('about', '').startswith('http://wiki.wolnepodreczniki.pl')
projects = set()
for m in book.media.filter(type='mp3'):
if form.is_valid():
formats = form.cleaned_data['formats']
if len(formats) == 0:
- formats = ['pdf', 'epub', 'odt', 'txt']
+ formats = ['pdf', 'epub', 'mobi', 'odt', 'txt']
# Create a ZIP archive
temp = tempfile.TemporaryFile()
if 'pdf' in formats and book.pdf_file:
filename = book.pdf_file.path
archive.write(filename, str('%s.pdf' % book.slug))
+ if 'mobi' in formats and book.mobi_file:
+ filename = book.mobi_file.path
+ archive.write(filename, str('%s.mobi' % book.slug))
if book.root_ancestor not in already and 'epub' in formats and book.root_ancestor.epub_file:
filename = book.root_ancestor.epub_file.path
archive.write(filename, str('%s.epub' % book.root_ancestor.slug))
"""
shelf = get_object_or_404(models.Tag, slug=shelf, category='set')
- formats = {'pdf': False, 'epub': False, 'odt': False, 'txt': False}
+ formats = {'pdf': False, 'epub': False, 'mobi': False, 'odt': False, 'txt': False}
for book in collect_books(models.Book.tagged.with_all(shelf)):
if book.pdf_file:
formats['pdf'] = True
if book.root_ancestor.epub_file:
formats['epub'] = True
+ if book.mobi_file:
+ formats['mobi'] = True
if book.txt_file:
formats['txt'] = True
for format in ('odt',):
return render_to_response('catalogue/book_info.html', locals(),
context_instance=RequestContext(request))
+
def tag_info(request, id):
tag = get_object_or_404(models.Tag, id=id)
return HttpResponse(tag.description)
+
+
+def download_zip(request, format, slug):
+ url = None
+ if format in ('pdf', 'epub', 'mobi'):
+ url = models.Book.zip_format(format)
+ elif format == 'audiobook' and slug is not None:
+ book = models.Book.objects.get(slug=slug)
+ url = book.zip_audiobooks()
+ else:
+ raise Http404('No format specified for zip package')
+ return HttpResponseRedirect(urlquote_plus(settings.MEDIA_URL + url, safe='/?='))