# TODO: why is this hard-coded ?
-def book_upload_path(ext=None):
+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:
name = slughifi(filename.split(".")[0])
else:
name = slughifi(media.name)
- return 'lektura/%s.%s' % (name, ext)
+ return 'lektura/%s.%s' % (name[:(maxlen-len('lektura/.%s' % ext))], ext)
return get_dynamic_path
from catalogue.tests.book_import import *
+from catalogue.tests.bookmedia import *
from catalogue.tests.search import *
from catalogue.tests.tags import *
from catalogue.tests.templatetags import *
--- /dev/null
+# -*- coding: utf-8 -*-
+
+from django.core.files.base import ContentFile
+
+from catalogue.test_utils import *
+from catalogue import models
+
+class BookMediaTests(WLTestCase):
+
+ def test_long_name(self):
+ file = ContentFile('X')
+ bm = models.BookMedia.objects.create(type="ogg",
+ name="Some very very very very very very very very very very very very very very very very long file name")
+ bm.file.save(bm.name, file)
+ bm.save()
+
+ # reload to see what was really saved
+ bm = models.BookMedia.objects.get(pk=bm.pk)
+ self.assertEqual(bm.file.size, 1)
+
# PIL
PIL>=1.1.6
mutagen>=1.17
-sorl-thumbnail>=3.2
+sorl-thumbnail>=3.2,<10
# home-brewed & dependencies
lxml>=2.2.2