aboutsummaryrefslogtreecommitdiff
path: root/uploader/genotypes/views.py
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2024-09-20 16:10:50 -0500
committerFrederick Muriuki Muriithi2024-09-20 16:10:50 -0500
commit27eec3300eddbc17214b3ff3ffbd8bea867db401 (patch)
treedf15cc72916a9055b192205cb63c3cfaf1bb424f /uploader/genotypes/views.py
parentd4fd4693423d99f500bfcd65cea42ed47e8d59e0 (diff)
downloadgn-uploader-27eec3300eddbc17214b3ff3ffbd8bea867db401.tar.gz
Initialise UI for managing genotype datasets.
Diffstat (limited to 'uploader/genotypes/views.py')
-rw-r--r--uploader/genotypes/views.py29
1 files changed, 27 insertions, 2 deletions
diff --git a/uploader/genotypes/views.py b/uploader/genotypes/views.py
index 8752b02..4158491 100644
--- a/uploader/genotypes/views.py
+++ b/uploader/genotypes/views.py
@@ -136,5 +136,30 @@ def list_markers(species_id: int):
@require_login
def view_dataset(species_id: int, population_id: int, dataset_id: int):
"""View details regarding a specific dataset."""
- return (f"Genotype dataset '{dataset_id}, from population '{population_id}' "
- f"of species '{species_id}'.")
+ with database_connection(app.config["SQL_URI"]) as conn:
+ species = species_by_id(conn, species_id)
+ if not bool(species):
+ flash("Invalid species provided!", "alert-danger")
+ return redirect(url_for("species.populations.genotypes.index"))
+
+ population = population_by_species_and_id(
+ conn, species_id, population_id)
+ if not bool(population):
+ flash("Invalid population selected!", "alert-danger")
+ return redirect(url_for(
+ "species.populations.genotypes.select_population",
+ species_id=species_id))
+
+ dataset = genotype_dataset(conn, species_id, population_id, dataset_id)
+ if not bool(dataset):
+ flash("Could not find such a dataset!", "alert-danger")
+ return redirect(url_for(
+ "species.populations.genotypes.list_genotypes",
+ species_id=species_id,
+ population_id=population_id))
+
+ return render_template("genotypes/view-dataset.html",
+ species=species,
+ population=population,
+ dataset=dataset,
+ activelink="view-dataset")