about summary refs log tree commit diff
path: root/uploader
diff options
context:
space:
mode:
Diffstat (limited to 'uploader')
-rw-r--r--uploader/species/views.py25
-rw-r--r--uploader/static/js/populations.js2
-rw-r--r--uploader/templates/species/macro-display-species-card.html27
-rw-r--r--uploader/templates/species/sui-base.html10
-rw-r--r--uploader/templates/species/sui-view-species.html91
5 files changed, 150 insertions, 5 deletions
diff --git a/uploader/species/views.py b/uploader/species/views.py
index cea2f68..a490b0f 100644
--- a/uploader/species/views.py
+++ b/uploader/species/views.py
@@ -15,6 +15,8 @@ from uploader.ui import make_template_renderer
 from uploader.oauth2.client import oauth2_get, oauth2_post
 from uploader.authorisation import require_login, require_token
 from uploader.datautils import order_by_family, enumerate_sequence
+from uploader.population.models import (populations_by_species,
+                                        population_by_species_and_id)
 
 from .models import (all_species,
                      save_species,
@@ -41,15 +43,30 @@ def list_species():
 @require_login
 def view_species(species_id: int):
     """View details of a particular species and menus to act upon it."""
+    streamlined_ui = request.args.get("streamlined_ui")
     with database_connection(app.config["SQL_URI"]) as conn:
         species = species_by_id(conn, species_id)
         if bool(species):
-            return render_template("species/view-species.html",
-                                   species=species,
-                                   activelink="view-species")
+            population = population_by_species_and_id(
+                conn, species_id, request.args.get("population_id"))
+            if bool(population):
+                return redirect(url_for("species.populations.view_population",
+                                        species_id=species_id,
+                                        population_id=population["Id"],
+                                        streamlined_ui=streamlined_ui))
+            return render_template(
+                ("species/sui-view-species.html"
+                 if bool(streamlined_ui)
+                 else "species/view-species.html"),
+                species=species,
+                activelink="view-species",
+                streamlined_ui=streamlined_ui,
+                populations=populations_by_species(conn, species["SpeciesId"]))
         flash("Could not find a species with the given identifier.",
               "alert-danger")
-        return redirect(url_for("species.view_species"))
+        return redirect(url_for(
+            ("base.index" if streamlined_ui else "species.view_species"),
+            streamlined_ui=streamlined_ui))
 
 @speciesbp.route("/create", methods=["GET", "POST"])
 @require_login
diff --git a/uploader/static/js/populations.js b/uploader/static/js/populations.js
index 89ededa..111ebb7 100644
--- a/uploader/static/js/populations.js
+++ b/uploader/static/js/populations.js
@@ -22,7 +22,7 @@ $(() => {
         {
             select: "single",
             paging: true,
-            scrollY: 700,
+            scrollY: 500,
             deferRender: true,
             scroller: true,
             scrollCollapse: true,
diff --git a/uploader/templates/species/macro-display-species-card.html b/uploader/templates/species/macro-display-species-card.html
index 166c7b9..d7c4082 100644
--- a/uploader/templates/species/macro-display-species-card.html
+++ b/uploader/templates/species/macro-display-species-card.html
@@ -20,3 +20,30 @@
   </div>
 </div>
 {%endmacro%}
+
+
+{%macro display_sui_species_card(species)%}
+<div class="row">
+  <table>
+    <caption>Selected Species</caption>
+    <tr>
+      <th>Name</th>
+      <td>{{species["Name"] | title}}</td>
+    </tr>
+    <tr>
+      <th>Scientific</th>
+      <td>{{species["FullName"]}}</td>
+    </tr>
+    {%if species["TaxonomyId"]%}
+    <tr>
+      <th>Taxonomy ID</th>
+      <td>
+        <a href="https://www.ncbi.nlm.nih.gov/Taxonomy/Browser/wwwtax.cgi?id={{species.TaxonomyId}}"
+           title="NCBI's Taxonomy Browser page for {{species.Name}}">
+          {{species.TaxonomyId}}</a>
+      </td>
+    </tr>
+    {%endif%}
+  </table>
+</div>
+{%endmacro%}
diff --git a/uploader/templates/species/sui-base.html b/uploader/templates/species/sui-base.html
new file mode 100644
index 0000000..5d2e6e3
--- /dev/null
+++ b/uploader/templates/species/sui-base.html
@@ -0,0 +1,10 @@
+{%extends "sui-base.html"%}
+
+{%block breadcrumbs%}
+{{super()}}
+<li class="breadcrumb-item">
+  <a href="{{url_for('species.view_species', species_id=species['SpeciesId'], streamlined_ui=streamlined_ui)}}">
+    {{species["Name"]|title}}
+  </a>
+</li>
+{%endblock%}
diff --git a/uploader/templates/species/sui-view-species.html b/uploader/templates/species/sui-view-species.html
new file mode 100644
index 0000000..5373766
--- /dev/null
+++ b/uploader/templates/species/sui-view-species.html
@@ -0,0 +1,91 @@
+{%extends "species/sui-base.html"%}
+{%from "flash_messages.html" import flash_all_messages%}
+{%from "macro-step-indicator.html" import step_indicator%}
+{%from "species/macro-display-species-card.html" import display_sui_species_card%}
+
+{%block title%}View Species{%endblock%}
+
+
+{%block contents%}
+<div class="row">
+  <h2>{{step_indicator("2(a)")}} Select the Population</h2>
+
+  <p>Data belonging to a particular species is further divided into one or more
+    populations for easier handling. Please select the population you want to work
+    with.</p>
+
+  <form method="GET"
+        action="{{url_for('species.view_species', species_id=species.SpeciesId)}}"
+        class="form-horizontal">
+    <input type="hidden" name="streamlined_ui" value="{{streamlined_ui}}" />
+    {%if populations | length != 0%}
+
+    <p class="form-text">Search for, and select the population from the table
+      below.</p>
+
+    <div style="margin-top:3em;">
+      <table id="tbl-select-population" class="table compact stripe"
+             data-populations-list='{{populations | tojson}}'>
+        <thead>
+          <tr>
+            <th></th>
+            <th>Population</th>
+          </tr>
+        </thead>
+
+        <tbody></tbody>
+      </table>
+    </div>
+
+    {%else%}
+    <p class="form-text">
+      There are no populations currently defined for {{species['FullName']}}
+      ({{species['SpeciesName']}}).</p>
+    {%endif%}
+
+    <div class="row form-buttons">
+      <div class="col">
+        <input type="submit"
+               value="use selected population"
+               class="btn btn-primary" />
+      </div>
+
+      <div class="col"><strong>OR</strong></div>
+
+      <div class="col">
+        <a href="url_for('species.population.create_population',
+                 species_id=species.SpeciesId,
+                 return_to='species.view_species',
+                 streamlined_ui=streamlined_ui)"
+           title="Create a new population for species '{{species.Name}}'."
+           class="btn btn-outline-info">
+          Create a new population
+        </a>
+      </div>
+    </div>
+
+  </form>
+</div>
+
+<div class="row">&nbsp;</div>
+
+<div class="row">
+  <h2>{{step_indicator("2(b)")}} Manage sequencing platforms</h2>
+  <p>Upload and manage the sequencing platforms for species
+    '{{species.Name | title}} ({{species.FullName}})'
+    <a href="{{url_for('species.platforms.list_platforms',
+             species_id=species.SpeciesId,
+             streamlined_ui=streamlined_ui)}}"
+       title="Manage sequencing platforms for {{species.Name}}">here</a>.
+  </p>
+</div>
+{%endblock%}
+
+{%block sidebarcontents%}
+{{display_sui_species_card(species)}}
+{%endblock%}
+
+
+{%block javascript%}
+<script type="text/javascript" src="/static/js/populations.js"></script>
+{%endblock%}