Browse Source

Allow deletion of dataset

For now, deletion of the actual data is not enabled.
Matthias Vogelgesang 7 years ago
parent
commit
866fe103b6
2 changed files with 9 additions and 4 deletions
  1. 5 1
      nova/templates/collection/list.html
  2. 4 3
      nova/views.py

+ 5 - 1
nova/templates/collection/list.html

@@ -19,7 +19,7 @@
     <img class="img-responsive" src="https://placeholdit.imgix.net/~text?txtsize=33&txt=%C3%97&w=64&h=64"/>
     {% endif %}
   </div>
-  <div class="col-lg-11">
+  <div class="col-lg-10">
     <h3 class="dataset-link">
       <a href="{{ url_for("show_dataset", name=collection.user.name, collection_name=collection.name, dataset_name=dataset.name) }}">{{ dataset.name }}</a>
     </h3>
@@ -29,6 +29,10 @@
     {% endif %}
     </p>
   </div>
+  <div class="col-lg-1">
+    <p>
+    <a href="{{ url_for("delete", dataset_id=dataset.id) }}" class="btn btn-warning"><i class="fa fa-trash" aria-hidden="true"></i></a></p>
+  </div>
 </div>
 {% endfor %}
 <div class="row">

+ 4 - 3
nova/views.py

@@ -455,8 +455,6 @@ def show_dataset(name, collection_name, dataset_name, path=''):
     children = Dataset.query.join(Process.destination).\
         filter(Process.source_id == dataset.id).all()
 
-    print parents
-
     parts = path.split('/')
     subpaths = []
 
@@ -491,6 +489,9 @@ def delete(dataset_id=None):
     if not access.owner:
         return redirect(url_for('index'))
 
+    process = Process.query.filter(Process.destination_id == dataset_id).first()
+    db.session.delete(process)
+
     shared_with = db.session.query(Access).\
         filter(Access.user != current_user).\
         filter(Access.dataset_id == dataset_id).all()
@@ -504,7 +505,7 @@ def delete(dataset_id=None):
         path = fs.path_of(dataset)
         db.session.delete(dataset)
         db.session.commit()
-        tasks.rmtree.delay(path)
+        app.logger.info("Would remove {}, however deletion is currently disabled".format(path))
 
     return redirect(url_for('index'))