X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/c6eaa20b4ddb98a2d085bb588224c36115334c52..a39b207ad55440ed2b3edcedd765a3228f8001e3:/apps/catalogue/models.py?ds=sidebyside diff --git a/apps/catalogue/models.py b/apps/catalogue/models.py index ab480d7fc..8411f477e 100644 --- a/apps/catalogue/models.py +++ b/apps/catalogue/models.py @@ -156,7 +156,7 @@ class Tag(TagBase): # 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: @@ -165,7 +165,7 @@ def book_upload_path(ext=None): 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