aboutsummaryrefslogtreecommitdiff
path: root/uploader/phenotypes
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2024-12-10 15:49:31 -0600
committerFrederick Muriuki Muriithi2024-12-10 15:49:31 -0600
commit5f7c3ed381c85aa554240e52fd8e85aafad6ca01 (patch)
treeadbeca2ae70d6cca7f0daad0f56076a7bbea0d8c /uploader/phenotypes
parent592096d059360ef85741107eb4fb8a5e3c5839c8 (diff)
downloadgn-uploader-5f7c3ed381c85aa554240e52fd8e85aafad6ca01.tar.gz
Redirect if there's only a single phenotype dataset
If a particular population has only a single phenotype dataset, redirect to the dataset view page rather than listing the only dataset.
Diffstat (limited to 'uploader/phenotypes')
-rw-r--r--uploader/phenotypes/views.py13
1 files changed, 9 insertions, 4 deletions
diff --git a/uploader/phenotypes/views.py b/uploader/phenotypes/views.py
index 44175a0..8a8ca42 100644
--- a/uploader/phenotypes/views.py
+++ b/uploader/phenotypes/views.py
@@ -103,13 +103,18 @@ def select_population(species: dict, **kwargs):# pylint: disable=[unused-argumen
def list_datasets(species: dict, population: dict, **kwargs):# pylint: disable=[unused-argument]
"""List available phenotype datasets."""
with database_connection(app.config["SQL_URI"]) as conn:
+ datasets = datasets_by_population(
+ conn, species["SpeciesId"], population["Id"])
+ if len(datasets) == 1:
+ return redirect(url_for(
+ "species.populations.phenotypes.view_dataset",
+ species_id=species["SpeciesId"],
+ population_id=population["Id"],
+ dataset_id=datasets[0]["Id"]))
return render_template("phenotypes/list-datasets.html",
species=species,
population=population,
- datasets=datasets_by_population(
- conn,
- species["SpeciesId"],
- population["Id"]),
+ datasets=datasets,
activelink="list-datasets")