From a64daab776d2b5637a11204848dc871e3f762308 Mon Sep 17 00:00:00 2001 From: zsloan Date: Tue, 2 Aug 2022 19:26:28 +0000 Subject: Move logic for creating authors display string to the server-side Python code --- wqflask/wqflask/search_results.py | 4 ++++ wqflask/wqflask/templates/search_result_page.html | 13 ++----------- 2 files changed, 6 insertions(+), 11 deletions(-) (limited to 'wqflask') diff --git a/wqflask/wqflask/search_results.py b/wqflask/wqflask/search_results.py index a82390cb..eb8879dd 100644 --- a/wqflask/wqflask/search_results.py +++ b/wqflask/wqflask/search_results.py @@ -172,6 +172,10 @@ class SearchResultPage: trait_dict['pubmed_text'] = result[4] trait_dict['authors'] = result[3] + trait_dict['authors_display'] = trait_dict['authors'] + author_list = trait_dict['authors'].split(",") + if len(author_list) >= 2: + trait_dict['authors_display'] = (",").join(author_list[:2]) + ", et al." if result[6] != "" and result[6] != None: trait_dict['mean'] = f"{result[6]:.3f}" diff --git a/wqflask/wqflask/templates/search_result_page.html b/wqflask/wqflask/templates/search_result_page.html index 62ee93cc..bd832420 100644 --- a/wqflask/wqflask/templates/search_result_page.html +++ b/wqflask/wqflask/templates/search_result_page.html @@ -319,17 +319,8 @@ {% else %} 'width': "500px", {% endif %} - 'data': null, - 'targets': 5, - 'render': function(data) { - author_list = data.authors.split(",") - if (author_list.length >= 2) { - author_string = author_list.slice(0, 2).join(",") + ", et al." - } else{ - author_string = data.authors - } - return author_string - } + 'data': "authors_display", + 'targets': 5 }, { 'title': "
Year
", -- cgit v1.2.3