From 641e42dd3c058054e941d86a620b09be83597b45 Mon Sep 17 00:00:00 2001 From: Laurent Gil Date: Tue, 21 May 2024 15:23:55 +0100 Subject: [PATCH] Fix Publication table display (mainly the header) in the 'Latest release' page --- catalog/tables.py | 29 +++++++++++++++++++++++++++++ catalog/views.py | 2 +- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/catalog/tables.py b/catalog/tables.py index 12e60d06..c0672cd7 100644 --- a/catalog/tables.py +++ b/catalog/tables.py @@ -350,6 +350,35 @@ class Meta: template_name = 'catalog/pgs_catalog_django_table.html' +class PublicationTable(tables.Table): + id = tables.Column(accessor='id', verbose_name=format_html('PGS
Publication/Study
ID (PGP)')) + scores_count = tables.Column(accessor='scores_count', verbose_name=format_html('PGS
Developed'), orderable=False) + scores_evaluated = tables.Column(accessor='scores_evaluated_count', verbose_name=format_html('PGS
Evaluated'), orderable=False) + doi = tables.Column(accessor='doi', verbose_name=format_html('Digital object identifier (doi)')) + PMID = tables.Column(accessor='PMID', verbose_name=format_html('PubMed ID
(PMID)')) + date_publication = tables.Column(accessor='date_publication', verbose_name=format_html('Publication
Date')) + class Meta: + model = Publication + attrs = { + "data-show-columns" : "true", + "data-sort-name" : "id", + "data-page-size" : page_size, + "data-export-options" : '{"fileName": "pgs_latest_publications_data"}' + } + fields = [ + 'id', + 'scores_count', + 'scores_evaluated', + 'firstauthor', + 'title', + 'journal', + 'date_publication', + 'doi', + 'PMID' + ] + template_name = 'catalog/pgs_catalog_django_table.html' + + class Browse_TraitTable(tables.Table): '''Table to browse Traits in the PGS Catalog''' label_link = Column_format_html(accessor='display_label', verbose_name=format_html('Trait (ontology term label)'), orderable=True) diff --git a/catalog/views.py b/catalog/views.py index e1fb6e34..5e7d7421 100644 --- a/catalog/views.py +++ b/catalog/views.py @@ -477,7 +477,7 @@ def latest_release(request): publication_defer = ['authors','curation_status','curation_notes'] publication_prefetch_related = [pgs_prefetch['publication_score'], pgs_prefetch['publication_performance']] publications = Publication.objects.defer(*publication_defer).filter(date_released=release_date).prefetch_related(*publication_prefetch_related) - publications_table = Browse_PublicationTable(publications, order_by="num") + publications_table = PublicationTable(publications, order_by="num") context['publications_table'] = publications_table context['publications_count'] = latest_release['publication_count']