sehmaschine/django-filebrowser — Issue #62: Default settings show extensionless files as folders
Author: dannyadair
Created: 2011-12-19 03:58:35+00:00
State: open

Despite the documentation at
http://readthedocs.org/docs/django-filebrowser/en/latest/settings.html#extensions-and-formats
saying

```python
EXTENSIONS = getattr(settings, "FILEBROWSER_EXTENSIONS", {
'Image': ['.jpg','.jpeg','.gif','.png','.tif','.tiff'],
'Document': ['.pdf','.doc','.rtf','.txt','.xls','.csv'],
'Video': ['.mov','.wmv','.mpeg','.mpg','.avi','.rm'],
'Audio': ['.mp3','.mp4','.wav','.aiff','.midi','.m4p']
})
```

https://github.com/sehmaschine/django-filebrowser/blob/master/filebrowser/settings.py
actually does

```python
# Allowed Extensions for File Upload. Lower case is important.
EXTENSIONS = getattr(settings, "FILEBROWSER_EXTENSIONS", {
'Folder': [''],
'Image': ['.jpg','.jpeg','.gif','.png','.tif','.tiff'],
'Document': ['.pdf','.doc','.rtf','.txt','.xls','.csv'],
'Video': ['.mov','.wmv','.mpeg','.mpg','.avi','.rm'],
'Audio': ['.mp3','.mp4','.wav','.aiff','.midi','.m4p']
})
```

FileObject.filetype
https://github.com/sehmaschine/django-filebrowser/blob/master/filebrowser/base.py#L214
will return 'Folder' if it's a directory, but if not determine from this dictionary. (The description "Allowed Extensions for File Upload" for this settings gives no hint about this other use)

At the same time,
https://github.com/sehmaschine/django-filebrowser/blob/master/filebrowser/templates/filebrowser/include/filelisting.html
checks fileobject.filetype to see if it's a folder and show a Browse link in that case.

This leads to files that have no extension being shown as Folders, and clicking on them gives "Folder does not exist".

filelisting.html needs to check filobject.is_folder instead, which let's the storage's isdir() decide.
I don't think the 'Folder' type for an empty extension should be in the default settings either.