aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2024-09-03 15:31:12 -0500
committerFrederick Muriuki Muriithi2024-09-03 16:51:27 -0500
commit2046919e5db5d1e7136f48641fe0adb701c145e4 (patch)
tree28f85290df7950497734254de0e18ccf702e153e
parent61688c00e8734adee4d825571a9c43d926dca001 (diff)
downloadgn-uploader-2046919e5db5d1e7136f48641fe0adb701c145e4.tar.gz
Put populations under species: improve hierarchy.
Populations cannot exist without the species they are related to. This commit updates the URI hierarchy to reflect that expectation.
-rw-r--r--uploader/__init__.py2
-rw-r--r--uploader/population/views.py14
-rw-r--r--uploader/species/views.py2
-rw-r--r--uploader/templates/base.html4
-rw-r--r--uploader/templates/populations/base.html6
-rw-r--r--uploader/templates/populations/index.html2
-rw-r--r--uploader/templates/populations/list-populations.html4
-rw-r--r--uploader/templates/species/base.html4
-rw-r--r--uploader/templates/species/create-species.html2
-rw-r--r--uploader/templates/species/view-species.html2
10 files changed, 21 insertions, 21 deletions
diff --git a/uploader/__init__.py b/uploader/__init__.py
index 5028f79..347f170 100644
--- a/uploader/__init__.py
+++ b/uploader/__init__.py
@@ -10,7 +10,6 @@ from flask_session import Session
from uploader.oauth2.client import user_logged_in, authserver_authorise_uri
from .base_routes import base
-from .population import popbp
from .species import speciesbp
from .dbinsert import dbinsertbp
from .oauth2.views import oauth2
@@ -84,7 +83,6 @@ def create_app():
app.register_blueprint(base, url_prefix="/")
app.register_blueprint(oauth2, url_prefix="/oauth2")
app.register_blueprint(speciesbp, url_prefix="/species")
- app.register_blueprint(popbp, url_prefix="/populations")
app.register_blueprint(dbinsertbp, url_prefix="/dbinsert")
app.register_blueprint(exprdatabp, url_prefix="/expression-data")
diff --git a/uploader/population/views.py b/uploader/population/views.py
index cd5e20b..3be46d4 100644
--- a/uploader/population/views.py
+++ b/uploader/population/views.py
@@ -21,7 +21,7 @@ popbp = Blueprint("populations", __name__)
render_template = make_template_renderer("populations")
-@popbp.route("/", methods=["GET", "POST"])
+@popbp.route("/populations", methods=["GET", "POST"])
@require_login
def index():
"""Entry point for populations."""
@@ -33,11 +33,11 @@ def index():
species = species_by_id(conn, request.args.get("species_id"))
if not bool(species):
flash("Invalid species identifier provided!", "alert-danger")
- return redirect(url_for("populations.index"))
- return redirect(url_for("populations.list_species_populations",
+ return redirect(url_for("species.populations.index"))
+ return redirect(url_for("species.populations.list_species_populations",
species_id=species["SpeciesId"]))
-@popbp.route("/<int:species_id>", methods=["GET"])
+@popbp.route("/<int:species_id>/populations", methods=["GET"])
@require_login
def list_species_populations(species_id: int):
"""List a particular species' populations."""
@@ -45,7 +45,7 @@ def list_species_populations(species_id: int):
species = species_by_id(conn, species_id)
if not bool(species):
flash("No species was found for given ID.", "alert-danger")
- return redirect(url_for("populations.index"))
+ return redirect(url_for("species.populations.index"))
return render_template(
"populations/list-populations.html",
species=species,
@@ -95,7 +95,7 @@ def create_population(species_id: int):
error = True
if error:
- return redirect(url_for("populations.create_population",
+ return redirect(url_for("species.populations.create_population",
**dict(request.args)))
new_population = save_population(conn, {
@@ -107,7 +107,7 @@ def create_population(species_id: int):
"Description": request.form.get("description") or None
})
- return redirect(url_for("populations.view_population",
+ return redirect(url_for("species.populations.view_population",
species_id=species["SpeciesId"],
population_id=new_population["InbredSetId"]))
diff --git a/uploader/species/views.py b/uploader/species/views.py
index 6f4d51f..77406a1 100644
--- a/uploader/species/views.py
+++ b/uploader/species/views.py
@@ -6,6 +6,7 @@ from flask import (flash,
Blueprint,
current_app as app)
+from uploader.population import popbp
from uploader.ui import make_template_renderer
from uploader.authorisation import require_login
from uploader.db_utils import database_connection
@@ -14,6 +15,7 @@ from .models import all_species, save_species, species_by_id
speciesbp = Blueprint("species", __name__)
+speciesbp.register_blueprint(popbp, url_prefix="/")
render_template = make_template_renderer("species")
diff --git a/uploader/templates/base.html b/uploader/templates/base.html
index fd6010b..d9696d0 100644
--- a/uploader/templates/base.html
+++ b/uploader/templates/base.html
@@ -45,7 +45,7 @@
<ul class="nav flex-column">
<li><a href="/" >Home</a></li>
<li><a href="{{url_for('species.list_species')}}" >Species</a></li>
- <li><a href="{{url_for('populations.index')}}">Populations</a></li>
+ <li><a href="{{url_for('species.populations.index')}}">Populations</a></li>
<li><a href="{{url_for('expression-data.index.index')}}" >Expression Data</a></li>
</ul>
</aside>
@@ -63,7 +63,7 @@
{%endif%}>
<a href="{{url_for('base.index')}}">Home</a>
</li>
- {%block breadcrumbs%}{%endblock%}
+ {%block lvl1_breadcrumbs%}{%endblock%}
</ol>
</nav>
</div>
diff --git a/uploader/templates/populations/base.html b/uploader/templates/populations/base.html
index 1033927..d763fc1 100644
--- a/uploader/templates/populations/base.html
+++ b/uploader/templates/populations/base.html
@@ -1,12 +1,12 @@
-{%extends "base.html"%}
+{%extends "species/base.html"%}
-{%block breadcrumbs%}
+{%block lvl2_breadcrumbs%}
<li {%if activelink=="populations"%}
class="breadcrumb-item active"
{%else%}
class="breadcrumb-item"
{%endif%}>
- <a href="{{url_for('populations.index')}}">Populations</a>
+ <a href="{{url_for('species.populations.index')}}">Populations</a>
</li>
{%block lvl3_breadcrumbs%}{%endblock%}
{%endblock%}
diff --git a/uploader/templates/populations/index.html b/uploader/templates/populations/index.html
index 14cf547..061ca1d 100644
--- a/uploader/templates/populations/index.html
+++ b/uploader/templates/populations/index.html
@@ -11,6 +11,6 @@
<div class="row">
To continue, you need to select the species:
- {{select_species_form(url_for("populations.index"), species)}}
+ {{select_species_form(url_for("species.populations.index"), species)}}
</div>
{%endblock%}
diff --git a/uploader/templates/populations/list-populations.html b/uploader/templates/populations/list-populations.html
index bf6cf98..c14a28c 100644
--- a/uploader/templates/populations/list-populations.html
+++ b/uploader/templates/populations/list-populations.html
@@ -12,7 +12,7 @@
{%else%}
class="breadcrumb-item"
{%endif%}>
- <a href="{{url_for('populations.list_species_populations',
+ <a href="{{url_for('species.populations.list_species_populations',
species_id=species.SpeciesId)}}">List</a>
</li>
{%endblock%}
@@ -35,7 +35,7 @@
exist, click on the "Create Population" button below to create a new one.
</p>
<p>
- <a href="{{url_for('populations.create_population',
+ <a href="{{url_for('species.populations.create_population',
species_id=species.SpeciesId)}}"
title="Create a new population for species '{{species.FullName}}'."
class="btn btn-danger">
diff --git a/uploader/templates/species/base.html b/uploader/templates/species/base.html
index 8fb697d..04391db 100644
--- a/uploader/templates/species/base.html
+++ b/uploader/templates/species/base.html
@@ -1,6 +1,6 @@
{%extends "base.html"%}
-{%block breadcrumbs%}
+{%block lvl1_breadcrumbs%}
<li {%if activelink=="species"%}
class="breadcrumb-item active"
{%else%}
@@ -8,5 +8,5 @@
{%endif%}>
<a href="{{url_for('species.list_species')}}">Species</a>
</li>
-{%block lvl3_breadcrumbs%}{%endblock%}
+{%block lvl2_breadcrumbs%}{%endblock%}
{%endblock%}
diff --git a/uploader/templates/species/create-species.html b/uploader/templates/species/create-species.html
index 678b010..1bc3b61 100644
--- a/uploader/templates/species/create-species.html
+++ b/uploader/templates/species/create-species.html
@@ -5,7 +5,7 @@
{%block pagetitle%}Create Species{%endblock%}
-{%block lvl3_breadcrumbs%}
+{%block lvl2_breadcrumbs%}
<li {%if activelink=="create-species"%}
class="breadcrumb-item active"
{%else%}
diff --git a/uploader/templates/species/view-species.html b/uploader/templates/species/view-species.html
index 0a3b0dd..0364c97 100644
--- a/uploader/templates/species/view-species.html
+++ b/uploader/templates/species/view-species.html
@@ -22,7 +22,7 @@
</style>
{%endblock%}
-{%block lvl3_breadcrumbs%}
+{%block lvl2_breadcrumbs%}
<li {%if activelink=="view-species"%}
class="breadcrumb-item active"
{%else%}