- return 'lektura/%s.%s' % (slugify(filename), ext)
+ if not media.name:
+ name = slugify(filename.split(".")[0])
+ else:
+ name = slugify(media.name)
+ return 'lektura/%s.%s' % (name, ext)
return get_dynamic_path
class BookMedia(models.Model):
type = models.CharField(_('type'), choices=MEDIA_FORMATS, max_length="100")
return get_dynamic_path
class BookMedia(models.Model):
type = models.CharField(_('type'), choices=MEDIA_FORMATS, max_length="100")
file = models.FileField(_('file'), upload_to=book_upload_path(), blank=True)
uploaded_at = models.DateTimeField(_('creation date'), auto_now_add=True, editable=False)
file = models.FileField(_('file'), upload_to=book_upload_path(), blank=True)
uploaded_at = models.DateTimeField(_('creation date'), auto_now_add=True, editable=False)
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)
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)
parent = models.ForeignKey('self', blank=True, null=True, related_name='children')
objects = models.Manager()
parent = models.ForeignKey('self', blank=True, null=True, related_name='children')
objects = models.Manager()
formats = [mark_safe(format) for format in formats]
setattr(self, key, unicode(render_to_string('catalogue/book_short.html',
formats = [mark_safe(format) for format in formats]
setattr(self, key, unicode(render_to_string('catalogue/book_short.html',