about summary refs log tree commit diff
diff options
context:
space:
mode:
authorzsloan2021-03-24 22:12:14 +0000
committerzsloan2021-03-24 22:12:14 +0000
commited911b95571948c8c34ff5f3286f322cc9cfbbcf (patch)
tree15134d00475b1903404572b45191e22647437e4d
parentf421a7b319696bb57b9ea4c0a3ec94a32fa4aa65 (diff)
downloadgenenetwork2-ed911b95571948c8c34ff5f3286f322cc9cfbbcf.tar.gz
Store a dictionary of maximum widths for each field + create a variable indicating if there are any wide columns (too wide to use DataTables' 'autoWidth' setting)
-rw-r--r--wqflask/wqflask/search_results.py14
1 files changed, 13 insertions, 1 deletions
diff --git a/wqflask/wqflask/search_results.py b/wqflask/wqflask/search_results.py
index f23c0582..c4d8d4ce 100644
--- a/wqflask/wqflask/search_results.py
+++ b/wqflask/wqflask/search_results.py
@@ -98,7 +98,6 @@ class SearchResultPage(object):
         species = webqtlDatabaseFunction.retrieve_species(self.dataset.group.name)
         # result_set represents the results for each search term; a search of
         # "shh grin2b" would have two sets of results, one for each term
-        logger.debug("self.results is:", pf(self.results))
 
         for index, result in enumerate(self.results):
             if not result:
@@ -164,6 +163,19 @@ class SearchResultPage(object):
                         trait_dict[key] = trait_dict[key].decode('utf-8')
                 trait_list.append(trait_dict)
 
+        self.max_widths = {}
+        for i, trait in enumerate(trait_list):
+            for key in trait.keys():
+                self.max_widths[key] = max(len(str(trait[key])), self.max_widths[key]) if key in self.max_widths else len(str(trait[key]))
+
+        self.wide_columns_exist = False
+        if this_trait.dataset.type == "Publish":
+            if (self.max_widths['display_name'] > 25 or self.max_widths['description'] > 100 or self.max_widths['authors']> 80):
+                self.wide_columns_exist = True
+        if this_trait.dataset.type == "ProbeSet":
+            if (self.max_widths['display_name'] > 25 or self.max_widths['symbol'] > 25 or self.max_widths['description'] > 100):
+                self.wide_columns_exist = True
+
         self.trait_list = trait_list
 
         if self.dataset.type == "ProbeSet":