fix video
[redakcja.git] / apps / fileupload / views.py
index 89ccf08..c7b9318 100644 (file)
@@ -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)