From 75add682a8d63a30e947b6bcd8d2e5dfee06c297 Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Tue, 18 Feb 2025 16:24:14 -0600 Subject: Use new searchable list tables with off-ramps for data creation. --- uploader/genotypes/views.py | 21 +++++++++++++++---- uploader/platforms/views.py | 8 +++++++- uploader/population/views.py | 10 ++++++++- uploader/samples/views.py | 24 ++++++++++++++++------ uploader/templates/genotypes/index.html | 4 ++++ .../templates/genotypes/select-population.html | 16 +++++---------- uploader/templates/phenotypes/index.html | 5 ----- uploader/templates/platforms/index.html | 4 ++++ uploader/templates/populations/index.html | 4 ++++ .../populations/macro-select-population.html | 4 ++++ uploader/templates/samples/index.html | 4 ++++ uploader/templates/samples/select-population.html | 23 +++++---------------- 12 files changed, 81 insertions(+), 46 deletions(-) (limited to 'uploader') diff --git a/uploader/genotypes/views.py b/uploader/genotypes/views.py index 0433420..5105730 100644 --- a/uploader/genotypes/views.py +++ b/uploader/genotypes/views.py @@ -35,8 +35,15 @@ def index(): with database_connection(app.config["SQL_URI"]) as conn: if not bool(request.args.get("species_id")): return render_template("genotypes/index.html", - species=order_by_family(all_species(conn)), + species=all_species(conn), activelink="genotypes") + + species_id = request.args.get("species_id") + if species_id == "CREATE-SPECIES": + return redirect(url_for( + "species.create_species", + return_to="species.populations.genotypes.select_population")) + species = species_by_id(conn, request.args.get("species_id")) if not bool(species): flash(f"Could not find species with ID '{request.args.get('species_id')}'!", @@ -56,11 +63,17 @@ def select_population(species: dict, species_id: int): if not bool(request.args.get("population_id")): return render_template("genotypes/select-population.html", species=species, - populations=order_by_family( - populations_by_species(conn, species_id), - order_key="FamilyOrder"), + populations=populations_by_species( + conn, species_id), activelink="genotypes") + population_id = request.args["population_id"] + if population_id == "CREATE-POPULATION": + return redirect(url_for( + "species.populations.create_population", + species_id=species["SpeciesId"], + return_to="species.populations.samples.list_genotypes")) + population = population_by_species_and_id( conn, species_id, request.args.get("population_id")) if not bool(population): diff --git a/uploader/platforms/views.py b/uploader/platforms/views.py index c20ab44..114c1a9 100644 --- a/uploader/platforms/views.py +++ b/uploader/platforms/views.py @@ -29,9 +29,15 @@ def index(): if not bool(request.args.get("species_id")): return render_template( "platforms/index.html", - species=order_by_family(all_species(conn)), + species=all_species(conn), activelink="platforms") + species_id = request.args.get("species_id") + if species_id == "CREATE-SPECIES": + return redirect(url_for( + "species.create_species", + return_to="species.platforms.list_platforms")) + species = species_by_id(conn, request.args["species_id"]) if not bool(species): flash("No species selected.", "alert-danger") diff --git a/uploader/population/views.py b/uploader/population/views.py index 1ece35f..f42e547 100644 --- a/uploader/population/views.py +++ b/uploader/population/views.py @@ -49,7 +49,15 @@ def index(): if not bool(request.args.get("species_id")): return render_template( "populations/index.html", - species=order_species_by_family(all_species(conn))) + species=all_species(conn), + activelink="populations") + + species_id = request.args.get("species_id") + if species_id == "CREATE-SPECIES": + return redirect(url_for( + "species.create_species", + return_to="species.populations.list_species_populations")) + species = species_by_id(conn, request.args.get("species_id")) if not bool(species): flash("Invalid species identifier provided!", "alert-danger") diff --git a/uploader/samples/views.py b/uploader/samples/views.py index ed79101..95a6f8c 100644 --- a/uploader/samples/views.py +++ b/uploader/samples/views.py @@ -40,8 +40,15 @@ def index(): if not bool(request.args.get("species_id")): return render_template( "samples/index.html", - species=order_species_by_family(all_species(conn)), + species=all_species(conn), activelink="samples") + + species_id = request.args.get("species_id") + if species_id == "CREATE-SPECIES": + return redirect(url_for( + "species.create_species", + return_to="species.populations.samples.select_population")) + species = species_by_id(conn, request.args.get("species_id")) if not bool(species): flash("No such species!", "alert-danger") @@ -63,13 +70,18 @@ def select_population(species_id: int): if not bool(request.args.get("population_id")): return render_template("samples/select-population.html", species=species, - populations=order_by_family( - populations_by_species( - conn, - species_id), - order_key="FamilyOrder"), + populations=populations_by_species( + conn, + species_id), activelink="samples") + population_id = request.args["population_id"] + if population_id == "CREATE-POPULATION": + return redirect(url_for( + "species.populations.create_population", + species_id=species["SpeciesId"], + return_to="species.populations.samples.list_samples")) + population = population_by_id(conn, request.args.get("population_id")) if not bool(population): flash("Population not found!", "alert-danger") diff --git a/uploader/templates/genotypes/index.html b/uploader/templates/genotypes/index.html index e749f5a..b50ebc5 100644 --- a/uploader/templates/genotypes/index.html +++ b/uploader/templates/genotypes/index.html @@ -26,3 +26,7 @@ species)}} {%endblock%} + +{%block javascript%} + +{%endblock%} diff --git a/uploader/templates/genotypes/select-population.html b/uploader/templates/genotypes/select-population.html index 7c81943..acdd063 100644 --- a/uploader/templates/genotypes/select-population.html +++ b/uploader/templates/genotypes/select-population.html @@ -12,20 +12,14 @@ {{flash_all_messages()}}
- You have indicated that you intend to upload the genotypes for species - '{{species.FullName}}'. We now just require the population for your - experiment/study, and you should be good to go. -
-You have selected "{{species.FullName}}" as the species that your data relates to.
-Next, we need information regarding the population your data relates to. Do please select the population from the existing ones below
-- If you cannot find the population your data relates to in the drop-down - above, you might want to - - add a new population to GeneNetwork - instead. + url_for("species.populations.samples.select_population", species_id=species.SpeciesId), species, populations)}}