From 895ae3ae28703d939d218429d15768649a53f18a Mon Sep 17 00:00:00 2001 From: zsloan Date: Thu, 23 Jun 2022 19:00:00 +0000 Subject: Convert trait.view to string for conversion to JSON It's originally a boolean, which causes an error when passed to the JS code as JSON --- wqflask/base/trait.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'wqflask/base') diff --git a/wqflask/base/trait.py b/wqflask/base/trait.py index 11b28c5c..0333e429 100644 --- a/wqflask/base/trait.py +++ b/wqflask/base/trait.py @@ -302,7 +302,7 @@ def jsonable(trait, dataset=None): if dataset.type == "ProbeSet": return dict(name=trait.name, - view=trait.view, + view=str(trait.view), symbol=trait.symbol, dataset=dataset.name, dataset_name=dataset.shortname, @@ -316,7 +316,7 @@ def jsonable(trait, dataset=None): elif dataset.type == "Publish": if trait.pubmed_id: return dict(name=trait.name, - view=trait.view, + view=str(trait.view), dataset=dataset.name, dataset_name=dataset.shortname, description=trait.description_display, @@ -332,7 +332,7 @@ def jsonable(trait, dataset=None): ) else: return dict(name=trait.name, - view=trait.view, + view=str(trait.view), dataset=dataset.name, dataset_name=dataset.shortname, description=trait.description_display, @@ -346,14 +346,14 @@ def jsonable(trait, dataset=None): ) elif dataset.type == "Geno": return dict(name=trait.name, - view=trait.view, + view=str(trait.view), dataset=dataset.name, dataset_name=dataset.shortname, location=trait.location_repr ) elif dataset.name == "Temp": return dict(name=trait.name, - view=trait.view, + view=str(trait.view), dataset="Temp", dataset_name="Temp") else: -- cgit v1.2.3 From 65768f80a4d5ec0320ca62355e5dec8e112b85c8 Mon Sep 17 00:00:00 2001 From: zsloan Date: Thu, 23 Jun 2022 20:10:13 +0000 Subject: Change jsonable in GeneralTrait so that it passes all necessary table information --- wqflask/base/trait.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'wqflask/base') diff --git a/wqflask/base/trait.py b/wqflask/base/trait.py index 0333e429..b02c6033 100644 --- a/wqflask/base/trait.py +++ b/wqflask/base/trait.py @@ -300,10 +300,16 @@ def jsonable(trait, dataset=None): dataset_type=trait.dataset.type, group_name=trait.dataset.group.name) + trait_symbol = "N/A" + if trait.symbol: + trait_symbol = trait.symbol + if dataset.type == "ProbeSet": return dict(name=trait.name, + display_name=trait.display_name, + hmac=hmac.data_hmac('{}:{}'.format(trait.display_name, dataset.name)), view=str(trait.view), - symbol=trait.symbol, + symbol=trait_symbol, dataset=dataset.name, dataset_name=dataset.shortname, description=trait.description_display, @@ -316,7 +322,10 @@ def jsonable(trait, dataset=None): elif dataset.type == "Publish": if trait.pubmed_id: return dict(name=trait.name, + display_name=trait.display_name, + hmac=hmac.data_hmac('{}:{}'.format(trait.display_name, dataset.name)), view=str(trait.view), + symbol=trait_symbol, dataset=dataset.name, dataset_name=dataset.shortname, description=trait.description_display, @@ -332,7 +341,10 @@ def jsonable(trait, dataset=None): ) else: return dict(name=trait.name, + display_name=trait.display_name, + hmac=hmac.data_hmac('{}:{}'.format(trait.display_name, dataset.name)), view=str(trait.view), + symbol=trait_symbol, dataset=dataset.name, dataset_name=dataset.shortname, description=trait.description_display, @@ -346,6 +358,8 @@ def jsonable(trait, dataset=None): ) elif dataset.type == "Geno": return dict(name=trait.name, + display_name=trait.display_name, + hmac=hmac.data_hmac('{}:{}'.format(trait.display_name, dataset.name)), view=str(trait.view), dataset=dataset.name, dataset_name=dataset.shortname, @@ -353,6 +367,8 @@ def jsonable(trait, dataset=None): ) elif dataset.name == "Temp": return dict(name=trait.name, + display_name=trait.display_name, + hmac=hmac.data_hmac('{}:{}'.format(trait.display_name, dataset.name)), view=str(trait.view), dataset="Temp", dataset_name="Temp") -- cgit v1.2.3