Browse Source

Add NOVA_ENABLE_FILE_LISTING option

Matthias Vogelgesang 7 years ago
parent
commit
cf792549c0
3 changed files with 16 additions and 8 deletions
  1. 1 0
      nova/settings.py
  2. 2 0
      nova/templates/dataset/detail.html
  3. 13 8
      nova/views.py

+ 1 - 0
nova/settings.py

@@ -1,4 +1,5 @@
 DEBUG = False
 NOVA_ROOT_PATH = '.'
+NOVA_ENABLE_FILE_LISTING = True
 SQLALCHEMY_TRACK_MODIFICATIONS = True
 CELERY_BROKER_URL = 'amqp://guest@localhost//'

+ 2 - 0
nova/templates/dataset/detail.html

@@ -74,6 +74,7 @@
   </div>
 </div>
 {% endif %}
+{% if list_files %}
 <div class="row">
   <div class="col-lg-12">
     <div class="page-header">
@@ -113,5 +114,6 @@
     </table>
   </div>
 </div>
+{% endif %}
 {% endblock %}
 

+ 13 - 8
nova/views.py

@@ -435,15 +435,20 @@ def show_dataset(name, collection_name, dataset_name, path=''):
     parts = path.split('/')
     subpaths = []
 
-    for part in parts:
-        if subpaths:
-            subpaths.append((part, os.path.join(subpaths[-1][1], part)))
-        else:
-            subpaths.append((part, part))
+    list_files = app.config['NOVA_ENABLE_FILE_LISTING']
+
+    dirs = fs.get_dirs(dataset, path) if list_files else None
+    files = sorted(fs.get_files(dataset, path)) if list_files else None
+
+    if list_files:
+        for part in parts:
+            if subpaths:
+                subpaths.append((part, os.path.join(subpaths[-1][1], part)))
+            else:
+                subpaths.append((part, part))
 
-    dirs = fs.get_dirs(dataset, path)
-    files = sorted(fs.get_files(dataset, path))
-    params = dict(dataset=dataset, path=path, subpaths=subpaths, files=files, dirs=dirs, origin=[])
+    params = dict(dataset=dataset, path=path, list_files=list_files,
+                  subpaths=subpaths, files=files, dirs=dirs, origin=[])
 
     return render_template('dataset/detail.html', **params)