From 5f7c3ed381c85aa554240e52fd8e85aafad6ca01 Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Tue, 10 Dec 2024 15:49:31 -0600 Subject: 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. --- uploader/phenotypes/views.py | 13 +++++++++---- 1 file 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") -- cgit v1.2.3