diff --git a/journals/models.py b/journals/models.py index 2e13ad41a8761f4dff24cb2243357312fb1ee8fd..07de757148e47caa0a7ad8d2670b41c7cfb5d628 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 0d93550d622ef38e17e3f19f7845f03c39db4116..30ccda4d3708c3c08d19bba876b5542c6574d9b1 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 cee84ead27a7c6baf10ad2881c5c8ba3050af14d..2890f139185a17a8c1d41beb7ceb5555d9e72e54 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 = ""