Lessons - HTMLized and added fixtures.
[wolnelektury.git] / apps / catalogue / views.py
index 82ca9fd..b69aa4a 100644 (file)
@@ -433,7 +433,7 @@ def find_best_matches(query, user=None):
                       if isinstance(match, models.Book))
     authors = set(match.name.lower() for match in result
                   if isinstance(match, models.Tag) and match.category=='author')
                       if isinstance(match, models.Book))
     authors = set(match.name.lower() for match in result
                   if isinstance(match, models.Tag) and match.category=='author')
-    result = (res for res in result if not (
+    result = tuple(res for res in result if not (
                  (isinstance(res, pdcounter_models.BookStub) and res.pretty_title().lower() in book_titles)
                  or (isinstance(res, pdcounter_models.Author) and res.name.lower() in authors)
              ))
                  (isinstance(res, pdcounter_models.BookStub) and res.pretty_title().lower() in book_titles)
                  or (isinstance(res, pdcounter_models.Author) and res.name.lower() in authors)
              ))
@@ -651,16 +651,11 @@ def shelf_book_formats(request, shelf):
             formats['pdf'] = True
         if book.root_ancestor.epub_file:
             formats['epub'] = True
             formats['pdf'] = True
         if book.root_ancestor.epub_file:
             formats['epub'] = True
-        if book.odt_file:
-            formats['odt'] = True
         if book.txt_file:
             formats['txt'] = True
         if book.txt_file:
             formats['txt'] = True
-        if book.mp3_file:
-            formats['mp3'] = True
-        if book.ogg_file:
-            formats['ogg'] = True
-        if book.daisy_file:
-            formats['daisy'] = True
+        for format in ('odt', 'mp3', 'ogg'):
+            if not formats[format] and book.has_media(format):
+                formats[format] = True
 
     return HttpResponse(LazyEncoder().encode(formats))
 
 
     return HttpResponse(LazyEncoder().encode(formats))