diff options
author | Frederick Muriuki Muriithi | 2025-05-05 11:51:25 -0500 |
---|---|---|
committer | Frederick Muriuki Muriithi | 2025-05-05 12:41:50 -0500 |
commit | 7057f7ddd0c14790398f65ae7ca1acf10da5a52e (patch) | |
tree | 6400fd5a75bcbf954ce7393a97109b9b25cf59eb | |
parent | 8ba9a5831041e41e6e2bec805f72635c6ac13e2c (diff) | |
download | gn-uploader-7057f7ddd0c14790398f65ae7ca1acf10da5a52e.tar.gz |
Include the publication when provided.
-rw-r--r-- | uploader/phenotypes/views.py | 14 | ||||
-rw-r--r-- | uploader/templates/phenotypes/add-phenotypes-raw-files.html | 1 | ||||
-rw-r--r-- | uploader/templates/phenotypes/review-job-data.html | 15 |
3 files changed, 26 insertions, 4 deletions
diff --git a/uploader/phenotypes/views.py b/uploader/phenotypes/views.py index 92a7c4b..20b95e2 100644 --- a/uploader/phenotypes/views.py +++ b/uploader/phenotypes/views.py @@ -40,6 +40,7 @@ from uploader.route_utils import generic_select_population from uploader.datautils import safe_int, enumerate_sequence from uploader.species.models import all_species, species_by_id from uploader.monadic_requests import make_either_error_handler +from uploader.publications.models import fetch_publication_by_id from uploader.request_checks import with_species, with_population from uploader.samples.models import samples_by_species_and_population from uploader.input_validation import (encode_errors, @@ -465,7 +466,9 @@ def add_phenotypes(species: dict, population: dict, dataset: dict, **kwargs):# p "speciesid": species["SpeciesId"], "populationid": population["Id"], "datasetid": dataset["Id"], - "bundle": str(phenobundle.absolute())})}), + "bundle": str(phenobundle.absolute()), + **({"publicationid": request.form["publication-id"]} + if request.form.get("publication-id") else {})})}), _redisuri, f"{app.config['UPLOAD_FOLDER']}/job_errors") @@ -538,7 +541,8 @@ def review_job_data( **kwargs ):# pylint: disable=[unused-argument] """Review data one more time before entering it into the database.""" - with Redis.from_url(app.config["REDIS_URL"], decode_responses=True) as rconn: + with (Redis.from_url(app.config["REDIS_URL"], decode_responses=True) as rconn, + database_connection(app.config["SQL_URI"]) as conn): try: job = jobs.job(rconn, jobs.jobsnamespace(), str(job_id)) except jobs.JobNotFound as _jnf: @@ -586,6 +590,7 @@ def review_job_data( filetype: __summarise__(filetype, meta) for filetype,meta in metadata.items() } + _job_metadata = json.loads(job["job-metadata"]) return render_template("phenotypes/review-job-data.html", species=species, population=population, @@ -593,6 +598,11 @@ def review_job_data( job_id=job_id, job=job, summary=summary, + publication=( + fetch_publication_by_id( + conn, int(_job_metadata["publicationid"])) + if _job_metadata.get("publicationid") + else None), activelink="add-phenotypes") diff --git a/uploader/templates/phenotypes/add-phenotypes-raw-files.html b/uploader/templates/phenotypes/add-phenotypes-raw-files.html index 2ff6a4f..5709491 100644 --- a/uploader/templates/phenotypes/add-phenotypes-raw-files.html +++ b/uploader/templates/phenotypes/add-phenotypes-raw-files.html @@ -585,6 +585,7 @@ })); }); formdata.append("resumable-upload", "true"); + formdata.append("publication-id", $("#txt-publication-id").val()); return formdata; } diff --git a/uploader/templates/phenotypes/review-job-data.html b/uploader/templates/phenotypes/review-job-data.html index 7bc8c62..befb5e2 100644 --- a/uploader/templates/phenotypes/review-job-data.html +++ b/uploader/templates/phenotypes/review-job-data.html @@ -40,9 +40,20 @@ species “<strong>{{species.SpeciesName}} ({{species.FullName}})</strong>” will be updated as follows:</p> + <ul> + {%if publication%} + <li>All {{summary.get("pheno", {}).get("total-data-rows", "0")}} phenotypes + are linked to the following publication: + <ul> + <li><strong>Publication Title:</strong> + {{publication.Title or "—"}}</li> + <li><strong>Author(s):</strong> + {{publication.Authors or "—"}}</li> + </ul> + </li> + {%endif%} {%for ftype in ("phenocovar", "pheno", "phenose", "phenonum")%} {%if summary.get(ftype, False)%} - <ul> <li>A total of {{summary[ftype]["number-of-files"]}} files will be processed adding {%if ftype == "phenocovar"%}(possibly){%endif%} {{summary[ftype]["total-data-rows"]}} new @@ -53,9 +64,9 @@ {%endif%} to the database. </li> - </ul> {%endif%} {%endfor%} + </ul> <a href="#" class="not-implemented btn btn-primary">continue</a> </div> |