about summary refs log tree commit diff
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2024-09-03 16:49:36 -0500
committerFrederick Muriuki Muriithi2024-09-03 16:51:28 -0500
commit795562b3855b2e4dca5632d53a922e84a2859bf0 (patch)
tree555a959e488941dadbef604add51feb609716290
parentf1add5f4ea332ddfb2e902fb8c38e88a1dbcf6a2 (diff)
downloadgn-uploader-795562b3855b2e4dca5632d53a922e84a2859bf0.tar.gz
View a specific population's details.
-rw-r--r--uploader/population/views.py24
-rw-r--r--uploader/templates/populations/list-populations.html4
-rw-r--r--uploader/templates/populations/view-population.html70
3 files changed, 95 insertions, 3 deletions
diff --git a/uploader/population/views.py b/uploader/population/views.py
index 3be46d4..e21465c 100644
--- a/uploader/population/views.py
+++ b/uploader/population/views.py
@@ -14,7 +14,8 @@ from uploader.species.models import (all_species,
                                      order_species_by_family)
 
 from .models import (save_population,
-                     populations_by_species)
+                     populations_by_species,
+                     population_by_species_and_id)
 
 __active_link__ = "populations"
 popbp = Blueprint("populations", __name__)
@@ -117,4 +118,23 @@ def create_population(species_id: int):
 @require_login
 def view_population(species_id: int, population_id: int):
     """View the details of a population."""
-    raise NotImplementedError("Please implement this too …")
+    with database_connection(app.config["SQL_URI"]) as conn:
+        species = species_by_id(conn, species_id)
+        population = population_by_species_and_id(conn, species_id, population_id)
+        error = False
+
+        if not bool(species):
+            flash("You must select a species.", "alert-danger")
+            error = True
+
+        if not bool(population):
+            flash("You must select a population.", "alert-danger")
+            error = True
+
+        if error:
+            return redirect(url_for("species.populations.index"))
+
+        return render_template("populations/view-population.html",
+                               species=species,
+                               population=population,
+                               activelink="view-population")
diff --git a/uploader/templates/populations/list-populations.html b/uploader/templates/populations/list-populations.html
index c14a28c..c3ba180 100644
--- a/uploader/templates/populations/list-populations.html
+++ b/uploader/templates/populations/list-populations.html
@@ -59,7 +59,9 @@
       {%for population in populations%}
       <tr>
         <td>
-          <a href="#{{population.InbredSetId}}"
+          <a href="{{url_for('species.populations.view_population',
+                   species_id=species.SpeciesId,
+                   population_id=population.InbredSetId)}}"
              title="Population '{{population.FullName}}' for species '{{species.FullName}}'.">
             {{population.Name}}
           </a>
diff --git a/uploader/templates/populations/view-population.html b/uploader/templates/populations/view-population.html
new file mode 100644
index 0000000..2ab7ca3
--- /dev/null
+++ b/uploader/templates/populations/view-population.html
@@ -0,0 +1,70 @@
+{%extends "populations/base.html"%}
+{%from "flash_messages.html" import flash_all_messages%}
+{%from "species/macro-select-species.html" import select_species_form%}
+
+{%block title%}Populations{%endblock%}
+
+{%block pagetitle%}Populations{%endblock%}
+
+{%block lvl3_breadcrumbs%}
+<li {%if activelink=="view-population"%}
+    class="breadcrumb-item active"
+    {%else%}
+    class="breadcrumb-item"
+    {%endif%}>
+  <a href="{{url_for('species.populations.view_population',
+           species_id=species.SpeciesId,
+           population_id=population.InbredSetId)}}">view population</a>
+</li>
+{%endblock%}
+
+
+{%block contents%}
+<div class="row">
+  <h2>Population Details</h2>
+  <dl>
+    <dt>Name</dt>
+    <dd>{{population.Name}}</dd>
+
+    <dt>FullName</dt>
+    <dd>{{population.FullName}}</dd>
+
+    <dt>Description</dt>
+    <dd>{{population.Description or "-"}}</dd>
+  </dl>
+</div>
+
+<div class="row">
+  <h3>Actions</h3>
+
+  <p>
+    Click any of the following links to use this population in performing the
+    subsequent operations.
+  </p>
+
+  <nav class="nav">
+    <ul>
+      <li>
+        <a href="#" title="Upload samples">upload samples</a>
+      </li>
+      <li>
+        <a href="#" title="Upload expression data">upload expression data</a>
+      </li>
+      <li>
+        <a href="#" title="Upload phenotype data">upload phenotype data</a>
+      </li>
+      <li>
+        <a href="#" title="Upload individual data">upload individual data</a>
+      </li>
+      <li>
+        <a href="#" title="Upload RNA-Seq data">upload RNA-Seq data</a>
+      </li>
+    </ul>
+  </nav>
+</div>
+{%endblock%}
+
+{%block sidebarcontents%}
+<p>&hellip; maybe provide species details here, perhaps? &hellip;</p>
+<p>&hellip; maybe provide extra population details here, perhaps? &hellip;</p>
+{%endblock%}