From b9a2e1239c6d9cbe233ad5dff7ed17ebfdf1c906 Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Wed, 10 Dec 2025 10:48:47 -0600 Subject: Implement streamlined UI for populations. --- uploader/population/views.py | 21 +++- .../populations/macro-display-population-card.html | 39 ++++++- uploader/templates/populations/sui-base.html | 13 +++ .../templates/populations/sui-view-population.html | 122 +++++++++++++++++++++ .../species/macro-display-species-card.html | 40 +++---- 5 files changed, 212 insertions(+), 23 deletions(-) create mode 100644 uploader/templates/populations/sui-base.html create mode 100644 uploader/templates/populations/sui-view-population.html (limited to 'uploader') diff --git a/uploader/population/views.py b/uploader/population/views.py index 87a33d9..cfc3b70 100644 --- a/uploader/population/views.py +++ b/uploader/population/views.py @@ -19,6 +19,7 @@ from uploader.authorisation import require_login from uploader.genotypes.views import genotypesbp from uploader.datautils import enumerate_sequence from uploader.phenotypes.views import phenotypesbp +from uploader.phenotypes.models import datasets_by_population from uploader.expression_data.views import exprdatabp from uploader.species.models import all_species, species_by_id from uploader.monadic_requests import make_either_error_handler @@ -193,10 +194,15 @@ def create_population(species_id: int): @require_login def view_population(species_id: int, population_id: int): """View the details of a population.""" + streamlined_ui = request.args.get("streamlined_ui") 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) + datasets = datasets_by_population(conn, species_id, population_id) error = False + if len(datasets) > 1: + error = True + flash("Got more than one dataset for the population.", "alert alert-danger") if not bool(species): flash("You must select a species.", "alert-danger") @@ -207,9 +213,18 @@ def view_population(species_id: int, population_id: int): error = True if error: - return redirect(url_for("species.populations.index")) + return redirect(url_for(("species.view_species" + if bool(streamlined_ui) + else "species.populations.index"), + species_id=species["SpeciesId"], + streamlined_ui=streamlined_ui)) - return render_template("populations/view-population.html", + return render_template(("populations/sui-view-population.html" + if bool(streamlined_ui) + else "populations/view-population.html"), species=species, population=population, - activelink="view-population") + **({"dataset": datasets[0]} if len(datasets) == 1 else {}), + activelink="view-population", + streamlined_ui=streamlined_ui, + view_under_construction=request.args.get("view_under_construction", False)) diff --git a/uploader/templates/populations/macro-display-population-card.html b/uploader/templates/populations/macro-display-population-card.html index 16b477f..6b5f1e0 100644 --- a/uploader/templates/populations/macro-display-population-card.html +++ b/uploader/templates/populations/macro-display-population-card.html @@ -1,4 +1,4 @@ -{%from "species/macro-display-species-card.html" import display_species_card%} +{%from "species/macro-display-species-card.html" import display_species_card,display_sui_species_card%} {%macro display_population_card(species, population)%} {{display_species_card(species)}} @@ -39,3 +39,40 @@ {%endmacro%} + + +{%macro display_sui_population_card(species, population)%} +{{display_sui_species_card(species)}} + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current population
Name{{population.Name}}
Full Name{{population.FullName}}
Code{{population.InbredSetCode}}
Genetic Type{{population.GeneticType}}
Family{{population.Family}}
+
+{%endmacro%} diff --git a/uploader/templates/populations/sui-base.html b/uploader/templates/populations/sui-base.html new file mode 100644 index 0000000..88d3f54 --- /dev/null +++ b/uploader/templates/populations/sui-base.html @@ -0,0 +1,13 @@ +{%extends "species/sui-base.html"%} + +{%block breadcrumbs%} +{{super()}} + +{%endblock%} diff --git a/uploader/templates/populations/sui-view-population.html b/uploader/templates/populations/sui-view-population.html new file mode 100644 index 0000000..a9f506a --- /dev/null +++ b/uploader/templates/populations/sui-view-population.html @@ -0,0 +1,122 @@ +{%extends "populations/sui-base.html"%} +{%from "macro-step-indicator.html" import step_indicator%} +{%from "populations/macro-display-population-card.html" import display_sui_population_card%} + +{%block contents%} +
+

{{step_indicator("3")}} Choose population action

+ +

The tabs below present the actions/features available under a population. + Do have a look at each to decide your next option.

+
+ +
+ +
+ +
+
+
+

Think of a "sample" as say a single case or individual + in the experiment. It could even be a single strain (where applicable) + under consideration.

+

This is a convenience feature for when you want to upload phenotypes to + the system, but do not have the genotypes data ready yet.

+

Please click the button below to provide the samples that will be used + in your data.

+ Upload Samples +
+ +
+

This will allow you to upload new phenotypes intended for publication + (or already published) to the system.

+

The new phenotypes will be grouped under the + "{{population.FullName}} ({{population.Name}})" population of + the "{{species.FullName}} ({{species.Name}})" species, as + selected in previous steps.

+

Please click the button below to proceed.

+ Upload Phenotypes +
+
+

This allows you to upload the data that concerns your genotypes.

+

Any samples/individuals/cases/strains that do not already exist in the + system will be added. This does not delete any existing data.

+ upload genotypes +
+
+

Upload expression data (mRNA data) for this population.

+ upload genotypes +
+
+
+{%endblock%} + +{%block sidebarcontents%} +{{display_sui_population_card(species, population)}} +{%endblock%} + + diff --git a/uploader/templates/species/macro-display-species-card.html b/uploader/templates/species/macro-display-species-card.html index d7c4082..30c564f 100644 --- a/uploader/templates/species/macro-display-species-card.html +++ b/uploader/templates/species/macro-display-species-card.html @@ -24,25 +24,27 @@ {%macro display_sui_species_card(species)%}
- - - - - - - - - - - {%if species["TaxonomyId"]%} - - - - +
Selected Species
Name{{species["Name"] | title}}
Scientific{{species["FullName"]}}
Taxonomy ID - - {{species.TaxonomyId}} -
+ + + + + + + + + + + {%if species["TaxonomyId"]%} + + + + + {%endif%}
Current Species
Name{{species["Name"] | title}}
Scientific{{species["FullName"]}}
Taxonomy ID + + {{species.TaxonomyId}} +
-- cgit 1.4.1