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 /uploader/phenotypes | |
parent | 8ba9a5831041e41e6e2bec805f72635c6ac13e2c (diff) | |
download | gn-uploader-7057f7ddd0c14790398f65ae7ca1acf10da5a52e.tar.gz |
Include the publication when provided.
Diffstat (limited to 'uploader/phenotypes')
-rw-r--r-- | uploader/phenotypes/views.py | 14 |
1 files changed, 12 insertions, 2 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") |