Repository: django-cms/django-filer

Issue:
remove automatic unzip
This has already been removed in the develop branch. Since it's pretty annoying in most cases it should be backported to the 0.8 support branch.

basically make https://github.com/stefanfoulis/django-filer/blob/support/0.8.x/filer/utils/files.py `generic_handle_file` do nothing.



Discussion:
Can't we just remove the function entirely and change clipboardadmin?

from

```
        clipboard, was_clipboard_created = Clipboard.objects.get_or_create(user=request.user)
        files = generic_handle_file(upload, filename)
```

to

```
        clipboard, was_clipboard_created = Clipboard.objects.get_or_create(user=request.user)
        files = [(upload, filename)]
```

If a fulltext search on the sourcecode does not reveal any other usages of `generic_handle_file` thats a great solution. `files` needs to be a list of tuples though. (I already corrected it in your comment).

Or even better, drop the `for` loop (https://github.com/stefanfoulis/django-filer/blob/60a918c9f4b6df5fea46a97473da08e19838413f/filer/admin/clipboardadmin.py#L83) instead. 


Resolving patch:
diff --git a/filer/admin/clipboardadmin.py b/filer/admin/clipboardadmin.py
--- a/filer/admin/clipboardadmin.py
+++ b/filer/admin/clipboardadmin.py
@@ -8,7 +8,6 @@
 from django.contrib.admin.models import User
 from django.conf import settings
 from filer.models import Clipboard, ClipboardItem, File, Image
-from filer.utils.files import generic_handle_file
 from filer.models import tools
 from filer import settings as filer_settings
 from filer.admin.tools import popup_param
@@ -19,6 +18,8 @@
 class UploadFileForm(forms.ModelForm):
     class Meta:
         model = File
+
+
 class UploadImageFileForm(forms.ModelForm):
     class Meta:
         model = Image
@@ -27,6 +28,8 @@ class Meta:
 # ModelAdmins
 class ClipboardItemInline(admin.TabularInline):
     model = ClipboardItem
+
+
 class ClipboardAdmin(admin.ModelAdmin):
     model = Clipboard
     inlines = [ ClipboardItemInline, ]
@@ -78,35 +81,33 @@ def ajax_upload(self, request, folder_id=None):
 
             # Get clipboad
             clipboard, was_clipboard_created = Clipboard.objects.get_or_create(user=request.user)
-            files = generic_handle_file(upload, filename)
             file_items = []
-            for ifile, iname in files:
+            try:
+                iext = os.path.splitext(filename)[1].lower()
+            except:
+                iext = ''
+            if iext in ['.jpg', '.jpeg', '.png', '.gif']:
+                uploadform = UploadImageFileForm({'original_filename':filename,
+                                                  'owner': request.user.pk},
+                                                {'file':upload})
+            else:
+                uploadform = UploadFileForm({'original_filename':filename,
+                                             'owner': request.user.pk},
+                                            {'file':upload})
+            if uploadform.is_valid():
                 try:
-                    iext = os.path.splitext(iname)[1].lower()
-                except:
-                    iext = ''
-                if iext in ['.jpg', '.jpeg', '.png', '.gif']:
-                    uploadform = UploadImageFileForm({'original_filename':iname,
-                                                      'owner': request.user.pk},
-                                                    {'file':ifile})
-                else:
-                    uploadform = UploadFileForm({'original_filename':iname,
-                                                 'owner': request.user.pk},
-                                                {'file':ifile})
-                if uploadform.is_valid():
-                    try:
-                        file = uploadform.save(commit=False)
-                        # Enforce the FILER_IS_PUBLIC_DEFAULT
-                        file.is_public = filer_settings.FILER_IS_PUBLIC_DEFAULT
-                        file.save()
-                        file_items.append(file)
-                        clipboard_item = ClipboardItem(clipboard=clipboard, file=file)
-                        clipboard_item.save()
-                    except Exception, e:
-                        #print e
-                        pass
-                else:
-                    pass#print uploadform.errors
+                    file = uploadform.save(commit=False)
+                    # Enforce the FILER_IS_PUBLIC_DEFAULT
+                    file.is_public = filer_settings.FILER_IS_PUBLIC_DEFAULT
+                    file.save()
+                    file_items.append(file)
+                    clipboard_item = ClipboardItem(clipboard=clipboard, file=file)
+                    clipboard_item.save()
+                except Exception, e:
+                    #print e
+                    pass
+            else:
+                pass#print uploadform.errors
         except Exception, e:
             #print e
             pass
diff --git a/filer/utils/files.py b/filer/utils/files.py
deleted file mode 100644
--- a/filer/utils/files.py
+++ /dev/null
@@ -1,21 +0,0 @@
-import os
-
-from filer.utils.zip import unzip
-
-def generic_handle_file(file, original_filename):
-    """
-    Handels a file, regardless if a package or a single file and returns 
-    a list of files. can recursively unpack packages.
-    """
-    #print "entering generic_handle_file(file=%s, original_filename=%s)" % (file, original_filename)
-    files = []
-    filetype = os.path.splitext(original_filename)[1].lower()
-    #print filetype
-    if filetype=='.zip':
-        unpacked_files = unzip(file)
-        for ufile, ufilename in unpacked_files:
-            files += generic_handle_file(ufile, ufilename)
-    else:
-        files.append( (file,original_filename) )
-    #print "result of generic_handle_file: ", files
-    return files
\ No newline at end of file


Test patch: