about summary refs log tree commit diff
path: root/uploader/population
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2025-02-18 11:10:29 -0600
committerFrederick Muriuki Muriithi2025-02-18 11:10:29 -0600
commit3c960f6cf885934e5f390390c9e0fae0d6b93d5d (patch)
treef62bcadb0be4b6239f2de9bf1b927461a7c4ddb7 /uploader/population
parent14714a035e267a17c7111aec7b047104a1c34d36 (diff)
downloadgn-uploader-3c960f6cf885934e5f390390c9e0fae0d6b93d5d.tar.gz
Enable creating new populations on the "Phenotype Data" path.
Enable creating new populations in the case where the population a
user wants to use does not exist in the database.
Diffstat (limited to 'uploader/population')
-rw-r--r--uploader/population/views.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/uploader/population/views.py b/uploader/population/views.py
index 4f985f5..1ece35f 100644
--- a/uploader/population/views.py
+++ b/uploader/population/views.py
@@ -5,6 +5,7 @@ import base64
 from MySQLdb.cursors import DictCursor
 from gn_libs.mysqldb import database_connection
 from flask import (flash,
+                   escape,
                    request,
                    url_for,
                    redirect,
@@ -101,6 +102,7 @@ def create_population(species_id: int):
                     {"id": "2", "value": "GEMMA"},
                     {"id": "3", "value": "R/qtl"},
                     {"id": "4", "value": "GEMMA, PLINK"}),
+                return_to=(request.args.get("return_to") or ""),
                 activelink="create-population",
                 **error_values)
 
@@ -151,7 +153,15 @@ def create_population(species_id: int):
         })
 
         def __flash_success__(_success):
-            flash("Successfully created resource.", "alert-success")
+            flash("Successfully created population "
+                  f"{escape(new_population['FullName'])}.",
+                  "alert-success")
+            return_to = request.form.get("return_to") or ""
+            if return_to:
+                return redirect(url_for(
+                    return_to,
+                    species_id=species["SpeciesId"],
+                    population_id=new_population["InbredSetId"]))
             return redirect(url_for(
                 "species.populations.view_population",
                 species_id=species["SpeciesId"],