X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/31006b86a2e9883d8a4c5fe18128821b325773ab..65272584c324400613b037432b3802f9956ef5d6:/apps/fileupload/views.py diff --git a/apps/fileupload/views.py b/apps/fileupload/views.py index 89ccf081..c7b93187 100644 --- a/apps/fileupload/views.py +++ b/apps/fileupload/views.py @@ -11,6 +11,8 @@ from django.http import HttpResponse, Http404 from django.utils.decorators import method_decorator from django.views.decorators.vary import vary_on_headers from django.views.generic import FormView +from unidecode import unidecode + from .forms import UploadForm @@ -23,7 +25,11 @@ except ImportError: else: def thumbnail(relpath): try: - return default.backend.get_thumbnail(relpath, "x50").url + thumb = default.backend.get_thumbnail(relpath, "x50") + if not thumb.exists(): + # That's not an image. No thumb. + return None + return thumb.url except IOError: # That's not an image. No thumb. return None @@ -135,6 +141,7 @@ class UploadView(UploadViewMixin, FormView): os.makedirs(path) data = [] for f in flist: + f.name = unidecode(f.name) with open(self.get_safe_path(f.name), 'w') as destination: for chunk in f.chunks(): destination.write(chunk)