Fixes #925 (xml source link on book's page).
[wolnelektury.git] / apps / catalogue / models.py
index 1e85cdf..98e37c1 100644 (file)
@@ -173,7 +173,7 @@ def book_upload_path(ext=None):
         # how to put related book's slug here?
         if not ext:
             ext = media.type
-        return 'lektura/%s.%s' % (slugify(filename), ext)
+        return 'lektura/%s.%s' % (slugify(media.name), ext)
     return get_dynamic_path
 
 
@@ -206,8 +206,9 @@ class Book(models.Model):
     html_file     = models.FileField(_('HTML file'), upload_to=book_upload_path('html'), blank=True)
     pdf_file      = models.FileField(_('PDF file'), upload_to=book_upload_path('pdf'), blank=True)
     epub_file     = models.FileField(_('EPUB file'), upload_to=book_upload_path('epub'), blank=True)    
+    txt_file      = models.FileField(_('TXT file'), upload_to=book_upload_path('txt'), blank=True)        
     # other files
-    medias        = models.ManyToManyField(BookMedia)
+    medias        = models.ManyToManyField(BookMedia, blank=True)
     
     parent        = models.ForeignKey('self', blank=True, null=True, related_name='children')
     objects  = models.Manager()