From 46f3e8c05250d129994dc7373a6cbd6d4363ce34 Mon Sep 17 00:00:00 2001 From: "J.-S. Caux" <J.S.Caux@uva.nl> Date: Wed, 3 Oct 2018 09:25:28 +0200 Subject: [PATCH] Improve publication detail page wrt organizations --- journals/models.py | 9 +++++++++ .../templates/journals/publication_detail.html | 17 +++++++++++++---- organizations/models.py | 16 +++++++++++++++- 3 files changed, 37 insertions(+), 5 deletions(-) diff --git a/journals/models.py b/journals/models.py index 2e13ad41a..07de75714 100644 --- a/journals/models.py +++ b/journals/models.py @@ -24,6 +24,7 @@ from scipost.constants import SCIPOST_DISCIPLINES, SCIPOST_SUBJECT_AREAS from scipost.fields import ChoiceArrayField + ################ # Journals etc # ################ @@ -492,6 +493,14 @@ class Publication(models.Model): return val raise KeyError + def get_all_affiliations(self): + """ + Returns all author affiliations. + """ + from organizations.models import Organization + return Organization.objects.filter( + publicationauthorstable__publication=self).distinct() + def get_all_funders(self): from funders.models import Funder return Funder.objects.filter( diff --git a/journals/templates/journals/publication_detail.html b/journals/templates/journals/publication_detail.html index 0d93550d6..30ccda4d3 100644 --- a/journals/templates/journals/publication_detail.html +++ b/journals/templates/journals/publication_detail.html @@ -96,7 +96,7 @@ <div class="row"> <div class="col-12"> - <h3>Authors</h3> + <h3>Author{{ publication.authors.all|length|pluralize }}</h3> <ul> {% for author in publication.authors.all %} {% if author.is_registered %} @@ -107,8 +107,15 @@ {% endfor %} </ul> + <h3>Affiliation{{ publication.get_all_affiliations|length|pluralize }}</h3> + <ul> + {% for aff in publication.get_all_affiliations %} + <li><a href="{{ aff.get_absolute_url }}">{{ aff.name_full }}</a></li> + {% endfor %} + </ul> + {% if publication.get_all_funders %} - <h3>Funder{{ publication.get_all_funders|length|pluralize }} for this publication</h3> + <h3>Funder{{ publication.get_all_funders|length|pluralize }} for the research work leading to this publication</h3> <ul> {% for funder in publication.get_all_funders %} <li><a href="{{ funder.get_absolute_url }}">{{ funder }}</a></li> @@ -116,14 +123,16 @@ </ul> {% endif %} + {% if is_scipost_admin or is_edcol_admin %} {% if publication.institutions.all %} - <h3>Institution{{ publication.institutions.all|pluralize }} related to this Publication</h3> + <h3>Institution{{ publication.institutions.all|pluralize }} related to this Publication (<span class="text-danger">Admin-only view, to be removed</span>)</h3> <ul> {% for institution in publication.institutions.all %} <li><a href="{{ institution.get_absolute_url }}">{{ institution }}</a></li> {% endfor %} </ul> - {% endif %} + {% endif %} + {% endif %} </div> </div> diff --git a/organizations/models.py b/organizations/models.py index cee84ead2..2890f1391 100644 --- a/organizations/models.py +++ b/organizations/models.py @@ -13,7 +13,7 @@ from django_countries.fields import CountryField from .constants import ORGANIZATION_TYPES, ORGANIZATION_STATUSES, ORGSTATUS_ACTIVE from scipost.models import Contributor -from journals.models import Publication, PublicationAuthorsTable, OrgPubFraction, UnregisteredAuthor +from journals.models import Publication, OrgPubFraction, UnregisteredAuthor class Organization(models.Model): """ @@ -66,6 +66,20 @@ class Organization(models.Model): def __str__(self): return self.name + def name_and_acronym(self): + if self.acronym: + return '%s (%s)' % (self.name, self.acronym) + return self.name + + def name_full(self): + text = '' + if self.name_original: + text += self.name_original + ' / ' + text += self.name + if self.acronym: + text += ' (' + self.acronym + ')' + return text + @property def full_name(self): full_name_str = "" -- GitLab