diff options
author | Frederick Muriuki Muriithi | 2024-12-10 15:49:31 -0600 |
---|---|---|
committer | Frederick Muriuki Muriithi | 2024-12-10 15:49:31 -0600 |
commit | 5f7c3ed381c85aa554240e52fd8e85aafad6ca01 (patch) | |
tree | adbeca2ae70d6cca7f0daad0f56076a7bbea0d8c /uploader/phenotypes | |
parent | 592096d059360ef85741107eb4fb8a5e3c5839c8 (diff) | |
download | gn-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.py | 13 |
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") |