about summary refs log tree commit diff
path: root/uploader/phenotypes/views.py
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2025-12-16 13:57:43 -0600
committerFrederick Muriuki Muriithi2025-12-16 13:57:43 -0600
commit6697dd9757a2b28f2ea29888128d829393f66e93 (patch)
tree9f7fc75913ac9092537d93c6a39227b7974ac313 /uploader/phenotypes/views.py
parent98993dc0be542b377e62c97031f29f63e83f7ed4 (diff)
downloadgn-uploader-6697dd9757a2b28f2ea29888128d829393f66e93.tar.gz
Move logic for loading streamlined-UI templates to reusable function
Diffstat (limited to 'uploader/phenotypes/views.py')
-rw-r--r--uploader/phenotypes/views.py65
1 files changed, 32 insertions, 33 deletions
diff --git a/uploader/phenotypes/views.py b/uploader/phenotypes/views.py
index 364fc79..5b32fc0 100644
--- a/uploader/phenotypes/views.py
+++ b/uploader/phenotypes/views.py
@@ -32,6 +32,8 @@ from r_qtl import r_qtl2_qc as rqc
 from r_qtl import exceptions as rqe
 
 
+from uploader.sui import sui_template
+
 from uploader import jobs
 from uploader import session
 from uploader.files import save_file
@@ -423,11 +425,10 @@ def add_phenotypes(species: dict, population: dict, dataset: dict, **kwargs):# p
     with Redis.from_url(_redisuri, decode_responses=True) as rconn:
         if request.method == "GET":
             today = datetime.date.today()
-            _sui="sui-" if request.args.get("streamlined_ui") else ""
             return render_template(
-                (f"phenotypes/{_sui}add-phenotypes-with-rqtl2-bundle.html"
-                 if use_bundle
-                 else f"phenotypes/{_sui}add-phenotypes-raw-files.html"),
+                sui_template("phenotypes/add-phenotypes-with-rqtl2-bundle.html"
+                             if use_bundle
+                             else f"phenotypes/add-phenotypes-raw-files.html"),
                 species=species,
                 population=population,
                 dataset=dataset,
@@ -514,8 +515,7 @@ def job_status(
         except jobs.JobNotFound as _jnf:
             job = None
 
-        _sui = "sui-" if bool(request.args.get("streamlined_ui")) else ""
-        return render_template(f"phenotypes/{_sui}job-status.html",
+        return render_template(sui_template("phenotypes/job-status.html"),
                                species=species,
                                population=population,
                                dataset=dataset,
@@ -595,8 +595,7 @@ def review_job_data(
             for filetype,meta in metadata.items()
         }
         _job_metadata = json.loads(job["job-metadata"])
-        _sui = "sui-" if bool(request.args.get("streamlined_ui")) else ""
-        return render_template(f"phenotypes/{_sui}review-job-data.html",
+        return render_template(sui_template("phenotypes/review-job-data.html"),
                                species=species,
                                population=population,
                                dataset=dataset,
@@ -986,34 +985,34 @@ def load_data_success(
                               _publication["Authors"],
                               (_publication["Title"] or ""))
                              if item != "")
-            _sui="sui-" if request.args.get("streamlined_ui") else ""
-            return render_template(f"phenotypes/{_sui}load-phenotypes-success.html",
-                                   species=species,
-                                   population=population,
-                                   dataset=dataset,
-                                   job=job,
-                                   search_page_uri=urlunparse(ParseResult(
-                                       scheme=gn2_uri.scheme,
-                                       netloc=gn2_uri.netloc,
-                                       path="/search",
-                                       params="",
-                                       query=urlencode({
-                                           "species": species["Name"],
-                                           "group": population["Name"],
-                                           "type": "Phenotypes",
-                                           "dataset": dataset["Name"],
-                                           "search_terms_or": (
-                                               # Very long URLs will cause
-                                               # errors.
+            return render_template(
+                sui_template("phenotypes/load-phenotypes-success.html"),
+                species=species,
+                population=population,
+                dataset=dataset,
+                job=job,
+                search_page_uri=urlunparse(ParseResult(
+                    scheme=gn2_uri.scheme,
+                    netloc=gn2_uri.netloc,
+                    path="/search",
+                    params="",
+                    query=urlencode({
+                        "species": species["Name"],
+                        "group": population["Name"],
+                        "type": "Phenotypes",
+                        "dataset": dataset["Name"],
+                        "search_terms_or": (
+                            # Very long URLs will cause
+                            # errors.
                                                " ".join(_xref_ids)
                                                if len(_xref_ids) <= 100
                                                else ""),
-                                           "search_terms_and": " ".join(
-                                               _search_terms).strip(),
-                                           "accession_id": "None",
-                                           "FormID": "searchResult"
-                                       }),
-                                       fragment="")))
+                        "search_terms_and": " ".join(
+                            _search_terms).strip(),
+                        "accession_id": "None",
+                        "FormID": "searchResult"
+                    }),
+                    fragment="")))
         except JobNotFound as _jnf:
             return render_template("jobs/job-not-found.html", job_id=job_id)