Browse Source

HUE-669. [fb] Filebrowser home button doesn't work

Romain Rigaux 13 years ago
parent
commit
b6f1e4881a

+ 1 - 1
apps/filebrowser/src/filebrowser/views.py

@@ -107,7 +107,7 @@ def view(request, path):
 
     # default_to_home is set in bootstrap.js
     home_dir_path = request.user.get_home_directory()
-    if request.GET.get('default_to_home') and request.fs.isdir(home_dir_path):
+    if 'default_to_home' in request.GET and request.fs.isdir(home_dir_path):
         return format_preserving_redirect(request, urlresolvers.reverse(view, kwargs=dict(path=home_dir_path)))
 
     try:

+ 5 - 0
apps/filebrowser/src/filebrowser/views_test.py

@@ -31,6 +31,7 @@ except ImportError:
   import simplejson as json
 
 import logging
+import re
 import urlparse
 
 LOG = logging.getLogger(__name__)
@@ -116,6 +117,10 @@ def test_listdir():
     c = make_logged_in_client()
     response = c.get('/filebrowser/view/test-filebrowser/')
     assert_equal(response.context['home_directory'], '/user/test')
+
+    response = c.get('/filebrowser/view/test-filebrowser/?default_to_home')
+    assert_true(re.search('/user/test$', response['Location']))
+
   finally:
     try:
       cluster.fs.rmtree('/test-filebrowser')