aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2025-02-18 16:24:14 -0600
committerFrederick Muriuki Muriithi2025-02-18 16:24:14 -0600
commit75add682a8d63a30e947b6bcd8d2e5dfee06c297 (patch)
tree45879792ca984fc5ef20933172742e48e4a40d97
parentc403183a504769af6b3aa25b5438e945efbc91ff (diff)
downloadgn-uploader-75add682a8d63a30e947b6bcd8d2e5dfee06c297.tar.gz
Use new searchable list tables with off-ramps for data creation.
-rw-r--r--uploader/genotypes/views.py21
-rw-r--r--uploader/platforms/views.py8
-rw-r--r--uploader/population/views.py10
-rw-r--r--uploader/samples/views.py24
-rw-r--r--uploader/templates/genotypes/index.html4
-rw-r--r--uploader/templates/genotypes/select-population.html16
-rw-r--r--uploader/templates/phenotypes/index.html5
-rw-r--r--uploader/templates/platforms/index.html4
-rw-r--r--uploader/templates/populations/index.html4
-rw-r--r--uploader/templates/populations/macro-select-population.html4
-rw-r--r--uploader/templates/samples/index.html4
-rw-r--r--uploader/templates/samples/select-population.html23
12 files changed, 81 insertions, 46 deletions
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)}}
</div>
{%endblock%}
+
+{%block javascript%}
+<script type="text/javascript" src="/static/js/species.js"></script>
+{%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()}}
<div class="row">
- <p>
- 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.
- </p>
-</div>
-
-<div class="row">
- {{select_population_form(url_for("species.populations.genotypes.select_population",
- species_id=species.SpeciesId),
- populations)}}
+ {{select_population_form(url_for("species.populations.genotypes.select_population", species_id=species.SpeciesId), species, populations)}}
</div>
{%endblock%}
{%block sidebarcontents%}
{{display_species_card(species)}}
{%endblock%}
+
+{%block javascript%}
+<script type="text/javascript" src="/static/js/populations.js"></script>
+{%endblock%}
diff --git a/uploader/templates/phenotypes/index.html b/uploader/templates/phenotypes/index.html
index bffc278..689c28e 100644
--- a/uploader/templates/phenotypes/index.html
+++ b/uploader/templates/phenotypes/index.html
@@ -18,9 +18,4 @@
{%block javascript%}
<script type="text/javascript" src="/static/js/species.js"></script>
-<script type="text/javascript">
- $(function() {
- speciesDataTable(JSON.parse($("#tbl-select-species").attr("data-species-list")));
- });
- </script>
{%endblock%}
diff --git a/uploader/templates/platforms/index.html b/uploader/templates/platforms/index.html
index 35b6464..555b444 100644
--- a/uploader/templates/platforms/index.html
+++ b/uploader/templates/platforms/index.html
@@ -19,3 +19,7 @@
{{select_species_form(url_for("species.platforms.index"), species)}}
</div>
{%endblock%}
+
+{%block javascript%}
+<script type="text/javascript" src="/static/js/species.js"></script>
+{%endblock%}
diff --git a/uploader/templates/populations/index.html b/uploader/templates/populations/index.html
index 4354e02..d2bee77 100644
--- a/uploader/templates/populations/index.html
+++ b/uploader/templates/populations/index.html
@@ -22,3 +22,7 @@
{{select_species_form(url_for("species.populations.index"), species)}}
</div>
{%endblock%}
+
+{%block javascript%}
+<script type="text/javascript" src="/static/js/species.js"></script>
+{%endblock%}
diff --git a/uploader/templates/populations/macro-select-population.html b/uploader/templates/populations/macro-select-population.html
index c223776..14b0510 100644
--- a/uploader/templates/populations/macro-select-population.html
+++ b/uploader/templates/populations/macro-select-population.html
@@ -42,6 +42,10 @@
({{species['SpeciesName']}}).<br />
Click "Continue" to create the first!</p>
<input type="hidden" name="population_id" value="CREATE-POPULATION" />
+
+ <div class="col-sm-offset-10 col-sm-2">
+ <input type="submit" value="continue" class="btn btn-primary" />
+ </div>
{%endif%}
</form>
diff --git a/uploader/templates/samples/index.html b/uploader/templates/samples/index.html
index ee4a63e..ee98734 100644
--- a/uploader/templates/samples/index.html
+++ b/uploader/templates/samples/index.html
@@ -17,3 +17,7 @@
{{select_species_form(url_for("species.populations.samples.index"), species)}}
</div>
{%endblock%}
+
+{%block javascript%}
+<script type="text/javascript" src="/static/js/species.js"></script>
+{%endblock%}
diff --git a/uploader/templates/samples/select-population.html b/uploader/templates/samples/select-population.html
index f437780..1cc7573 100644
--- a/uploader/templates/samples/select-population.html
+++ b/uploader/templates/samples/select-population.html
@@ -12,28 +12,15 @@
{{flash_all_messages()}}
<div class="row">
- <p>You have selected "{{species.FullName}}" as the species that your data relates to.</p>
- <p>Next, we need information regarding the population your data relates to. Do please select the population from the existing ones below</p>
-</div>
-
-<div class="row">
{{select_population_form(
- url_for("species.populations.samples.select_population", species_id=species.SpeciesId),
- populations)}}
-</div>
-
-<div class="row">
- <p>
- If you cannot find the population your data relates to in the drop-down
- above, you might want to
- <a href="{{url_for('species.populations.create_population',
- species_id=species.SpeciesId)}}"
- title="Create a new population for species '{{species.FullName}},">
- add a new population to GeneNetwork</a>
- instead.
+ url_for("species.populations.samples.select_population", species_id=species.SpeciesId), species, populations)}}
</div>
{%endblock%}
{%block sidebarcontents%}
{{display_species_card(species)}}
{%endblock%}
+
+{%block javascript%}
+<script type="text/javascript" src="/static/js/populations.js"></script>
+{%endblock%}