daisy & lesmianator fix
authorRadek Czajka <radoslaw.czajka@nowoczesnapolska.org.pl>
Mon, 14 Feb 2011 14:45:47 +0000 (15:45 +0100)
committerRadek Czajka <radoslaw.czajka@nowoczesnapolska.org.pl>
Mon, 14 Feb 2011 14:45:47 +0000 (15:45 +0100)
apps/catalogue/models.py
apps/lesmianator/views.py

index b78b593..00baa28 100644 (file)
@@ -160,7 +160,10 @@ def book_upload_path(ext=None, maxlen=100):
     def get_dynamic_path(media, filename, ext=ext):
         # how to put related book's slug here?
         if not ext:
     def get_dynamic_path(media, filename, ext=ext):
         # how to put related book's slug here?
         if not ext:
-            ext = media.type
+            if media.type == 'daisy':
+                ext = 'daisy.zip'
+            else:
+                ext = media.type
         if not media.name:
             name = slughifi(filename.split(".")[0])
         else:
         if not media.name:
             name = slughifi(filename.split(".")[0])
         else:
index bb0a562..56acb57 100644 (file)
@@ -66,8 +66,11 @@ def poem_from_set(request, shelf):
 def get_poem(request, poem):
     p = get_object_or_404(Poem, slug=poem)
     p.visit()
 def get_poem(request, poem):
     p = get_object_or_404(Poem, slug=poem)
     p.visit()
-    books = Book.objects.filter(id__in=p.get_created_from_value())
-    book = books[0] if len(books) == 1 else None
+    if p.created_from:
+        books = Book.objects.filter(id__in=p.get_created_from_value())
+        book = books[0] if len(books) == 1 else None
+    else:
+        books = book = None
 
     return render_to_response('lesmianator/poem.html', 
                 {"poem": p, "books": books, "book": book},
 
     return render_to_response('lesmianator/poem.html', 
                 {"poem": p, "books": books, "book": book},