+@cache.never_cache
+def shelf_book_formats(request, shelf):
+ """"
+ Returns a list of formats of books in shelf.
+ """
+ shelf = get_object_or_404(models.Tag, slug=shelf, category='set')
+
+ formats = {'pdf': False, 'odt': False, 'txt': False, 'mp3': False, 'ogg': False}
+
+ for book in collect_books(models.Book.tagged.with_all(shelf)):
+ if book.pdf_file:
+ formats['pdf'] = True
+ if book.odt_file:
+ formats['odt'] = True
+ if book.txt_file:
+ formats['txt'] = True
+ if book.mp3_file:
+ formats['mp3'] = True
+ if book.ogg_file:
+ formats['ogg'] = True
+
+ return HttpResponse(LazyEncoder().encode(formats))
+
+