aboutsummaryrefslogtreecommitdiff
path: root/uploader/genotypes
diff options
context:
space:
mode:
Diffstat (limited to 'uploader/genotypes')
-rw-r--r--uploader/genotypes/views.py42
1 files changed, 12 insertions, 30 deletions
diff --git a/uploader/genotypes/views.py b/uploader/genotypes/views.py
index 5105730..54c2444 100644
--- a/uploader/genotypes/views.py
+++ b/uploader/genotypes/views.py
@@ -12,12 +12,12 @@ from flask import (flash,
from uploader.ui import make_template_renderer
from uploader.oauth2.client import oauth2_post
from uploader.authorisation import require_login
+from uploader.route_utils import generic_select_population
+from uploader.datautils import safe_int, enumerate_sequence
from uploader.species.models import all_species, species_by_id
from uploader.monadic_requests import make_either_error_handler
from uploader.request_checks import with_species, with_population
-from uploader.datautils import safe_int, order_by_family, enumerate_sequence
-from uploader.population.models import (populations_by_species,
- population_by_species_and_id)
+from uploader.population.models import population_by_species_and_id
from .models import (genotype_markers,
genotype_dataset,
@@ -57,34 +57,16 @@ def index():
methods=["GET"])
@require_login
@with_species(redirect_uri="species.populations.genotypes.index")
-def select_population(species: dict, species_id: int):
+def select_population(species: dict, species_id: int):# pylint: disable=[unused-argument]
"""Select the population under which the genotypes go."""
- with database_connection(app.config["SQL_URI"]) as conn:
- if not bool(request.args.get("population_id")):
- return render_template("genotypes/select-population.html",
- species=species,
- 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):
- flash("Invalid population selected!", "alert-danger")
- return redirect(url_for(
- "species.populations.genotypes.select_population",
- species_id=species_id))
-
- return redirect(url_for("species.populations.genotypes.list_genotypes",
- species_id=species_id,
- population_id=population["Id"]))
+ return generic_select_population(
+ species,
+ "genotypes/select-population.html",
+ request.args.get("population_id") or "",
+ "species.populations.genotypes.select_population",
+ "species.populations.genotypes.list_genotypes",
+ "genotypes",
+ "Invalid population selected!")
@genotypesbp.route(