about summary refs log tree commit diff
path: root/uploader/phenotypes/views.py
diff options
context:
space:
mode:
Diffstat (limited to 'uploader/phenotypes/views.py')
-rw-r--r--uploader/phenotypes/views.py35
1 files changed, 24 insertions, 11 deletions
diff --git a/uploader/phenotypes/views.py b/uploader/phenotypes/views.py
index f7d8e55..5ade24d 100644
--- a/uploader/phenotypes/views.py
+++ b/uploader/phenotypes/views.py
@@ -1173,15 +1173,28 @@ def delete_phenotypes(# pylint: disable=[unused-argument]
         **kwargs
 ):
     """Delete the specified phenotype data."""
-    if request.form.get("confirm", "").lower() == "confirm":
-        return f"Would delete! {request.form}"
-
     with database_connection(app.config["SQL_URI"]) as conn:
-        xref_ids = tuple(
-            int(item) for item in set(request.form.getlist("xref_ids")))
-        return render_template(
-            "phenotypes/confirm-delete-phenotypes.html",
-            species=species,
-            population=population,
-            dataset=dataset,
-            phenotypes=xref_ids)
+        form = request.form
+        xref_ids = tuple(int(item) for item in set(form.getlist("xref_ids")))
+
+        match form.get("action"):
+            case "cancel":
+                return redirect(url_for(
+                    "species.populations.phenotypes.view_dataset",
+                    species_id=species["SpeciesId"],
+                    population_id=population["Id"],
+                    dataset_id=dataset["Id"]))
+            case "delete":
+                # delete everything
+                # python3 -m scripts.phenotypes.delete_phenotypes <mariadburi> <authdburi> <speciesid> <populationid>
+                #
+                # delete selected phenotypes
+                # python3 -m scripts.phenotypes.delete_phenotypes <mariadburi> <authdburi> <speciesid> <populationid> --xref-ids-file=/path/to/file.txt
+                return "Would actually delete the data!"
+            case _:
+                return render_template(
+                    "phenotypes/confirm-delete-phenotypes.html",
+                    species=species,
+                    population=population,
+                    dataset=dataset,
+                    phenotypes=xref_ids)