Skip to content

Commit

Permalink
Handle sorting when date or filesize is None (happens for folders in S3)
Browse files Browse the repository at this point in the history
  • Loading branch information
michael.herring committed Nov 13, 2015
1 parent aa2b9fb commit bb2440f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion filebrowser_safe/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,10 @@ def browse(request):
# SORTING
query['o'] = request.GET.get('o', DEFAULT_SORTING_BY)
query['ot'] = request.GET.get('ot', DEFAULT_SORTING_ORDER)
files = sorted(files, key=lambda f: getattr(f, request.GET.get('o', DEFAULT_SORTING_BY)))
defaultValue = ''
if query['o'] in ['date', 'filesize']:
defaultValue = 0.0
files = sorted(files, key=lambda f: getattr(f, query['o']) or defaultValue)
if not request.GET.get('ot') and DEFAULT_SORTING_ORDER == "desc" or request.GET.get('ot') == "desc":
files.reverse()

Expand Down

0 comments on commit bb2440f

Please sign in to comment.