From 00a8f9996f19a95d8f5840993d504e06cb585dfa Mon Sep 17 00:00:00 2001 From: zsloan Date: Tue, 14 Feb 2023 22:32:35 +0000 Subject: Fix collection page error when ProbeSet/Publish traits don't have a mean --- wqflask/base/trait.py | 10 +++++++--- wqflask/wqflask/templates/collections/view.html | 6 +++++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/wqflask/base/trait.py b/wqflask/base/trait.py index 4352c527..7501306a 100644 --- a/wqflask/base/trait.py +++ b/wqflask/base/trait.py @@ -300,9 +300,13 @@ def jsonable(trait, dataset=None): dataset_type=trait.dataset.type, group_name=trait.dataset.group.name) + trait_symbol = "N/A" + trait_mean = "N/A" if trait.symbol: trait_symbol = trait.symbol + if trait.mean: + trait_mean = trait.mean if dataset.type == "ProbeSet": return dict(name=trait.name, @@ -313,7 +317,7 @@ def jsonable(trait, dataset=None): dataset=dataset.name, dataset_name=dataset.shortname, description=trait.description_display, - mean=trait.mean, + mean=trait_mean, location=trait.location_repr, chr=trait.chr, mb=trait.mb, @@ -338,7 +342,7 @@ def jsonable(trait, dataset=None): pubmed_id=trait.pubmed_id, pubmed_text=trait.pubmed_text, pubmed_link=trait.pubmed_link, - mean=trait.mean, + mean=trait_mean, lrs_score=trait.LRS_score_repr, lrs_location=trait.LRS_location_repr, lrs_chr=trait.locus_chr, @@ -357,7 +361,7 @@ def jsonable(trait, dataset=None): abbreviation=trait.abbreviation, authors=trait.authors, pubmed_text=trait.pubmed_text, - mean=trait.mean, + mean=trait_mean, lrs_score=trait.LRS_score_repr, lrs_location=trait.LRS_location_repr, lrs_chr=trait.locus_chr, diff --git a/wqflask/wqflask/templates/collections/view.html b/wqflask/wqflask/templates/collections/view.html index 3d7098af..1d9b7bcd 100644 --- a/wqflask/wqflask/templates/collections/view.html +++ b/wqflask/wqflask/templates/collections/view.html @@ -239,7 +239,11 @@ 'orderSequence': [ "desc", "asc"], 'render': function(data) { if (Object.hasOwn(data, 'mean')){ - return data.mean.toFixed(3) + if (data.mean != 'N/A'){ + return data.mean.toFixed(3) + } else { + return "N/A" + } } else { return "N/A" } -- cgit v1.2.3