template_name='catalogue/daisy_list.html')
-def counters(request):
- form = forms.SearchForm()
-
- books = models.Book.objects.count()
- books_nonempty = models.Book.objects.exclude(html_file='').count()
- books_empty = models.Book.objects.filter(html_file='').count()
- books_root = models.Book.objects.filter(parent=None).count()
-
- media = models.BookMedia.objects.count()
- media_types = models.BookMedia.objects.values('type').\
- annotate(count=Count('type')).\
- order_by('type')
- for mt in media_types:
- mt['size'] = sum(b.file.size for b in models.BookMedia.objects.filter(type=mt['type']))
- mt['deprecated'] = models.BookMedia.objects.filter(
- type=mt['type'], source_sha1=None).count() if mt['type'] in ('mp3', 'ogg') else '-'
-
- return render_to_response('catalogue/counters.html',
- locals(), context_instance=RequestContext(request))
-
-
def differentiate_tags(request, tags, ambiguous_slugs):
beginning = '/'.join(tag.url_chunk for tag in tags)
unparsed = '/'.join(ambiguous_slugs[1:])
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'):
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 == 'pdf':
+ url = models.Book.zip_pdf()
+ elif format == 'epub':
+ url = models.Book.zip_epub()
+ 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='/?='))