Commits

Luke Plant  committed 67cdb5c

Fixed file uploads so that spaces are not stripped from file names

  • Participants
  • Parent commits 5cb80c1

Comments (0)

Files changed (2)

File christchurch/files.py

+import re
+
+from django.core.files.storage import FileSystemStorage
+from django.utils.encoding import force_unicode
+
+
+class FriendlyFileSystemStorage(FileSystemStorage):
+
+    def get_valid_name(self, name):
+        # Spaces are fine in names, underscores are ugly, so we override the
+        # base implementation.
+        return re.sub(r'(?u)[^-\w. ]', '', force_unicode(name).strip())
+

File christchurch/settings.py

 
 FILE_UPLOAD_MAX_MEMORY_SIZE = 262144
 
+DEFAULT_FILE_STORAGE = 'christchurch.files.FriendlyFileSystemStorage'
+
+
 #####  EMAIL  #######
 
 if DEVBOX: