minor fix
[wolnelektury.git] / apps / catalogue / models.py
index b78b593..4552962 100644 (file)
@@ -160,12 +160,15 @@ 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:
-            ext = media.type
+            if media.type == 'daisy':
+                ext = 'daisy.zip'
+            else:
+                ext = media.type
         if not media.name:
             name = slughifi(filename.split(".")[0])
         else:
             name = slughifi(media.name)
-        return 'lektura/%s.%s' % (name[:(maxlen-len('lektura/.%s' % ext))], ext)
+        return 'lektura/%s.%s' % (name[:maxlen-len('lektura/.%s' % ext)-4], ext)
     return get_dynamic_path
 
 
@@ -555,7 +558,7 @@ class Book(models.Model):
                     tag.save()
                 book_tags.append(tag)
 
-        book.tags = book_tags + book_shelves
+        book.tags = set(book_tags + book_shelves)
 
         book_tag = book.book_tag()