SciPost Code Repository

Skip to content
Snippets Groups Projects
Commit ee4dd6a7 authored by Jean-Sébastien Caux's avatar Jean-Sébastien Caux
Browse files

Improve author - organization ordering

parent 47a03410
No related branches found
No related tags found
No related merge requests found
...@@ -7,7 +7,7 @@ from django.contrib.contenttypes.models import ContentType ...@@ -7,7 +7,7 @@ from django.contrib.contenttypes.models import ContentType
from django.contrib.postgres.fields import JSONField from django.contrib.postgres.fields import JSONField
from django.core.exceptions import ValidationError from django.core.exceptions import ValidationError
from django.db import models from django.db import models
from django.db.models import Avg, Sum, F from django.db.models import Avg, Min, Sum, F
from django.utils import timezone from django.utils import timezone
from django.urls import reverse from django.urls import reverse
...@@ -499,7 +499,8 @@ class Publication(models.Model): ...@@ -499,7 +499,8 @@ class Publication(models.Model):
""" """
from organizations.models import Organization from organizations.models import Organization
return Organization.objects.filter( return Organization.objects.filter(
publicationauthorstable__publication=self).distinct() publicationauthorstable__publication=self
).annotate(order=Min('publicationauthorstable__order')).order_by('order')
def get_all_funders(self): def get_all_funders(self):
from funders.models import Funder from funders.models import Funder
......
...@@ -96,49 +96,49 @@ ...@@ -96,49 +96,49 @@
<hr/> <hr/>
<div class="row"> <div class="row">
<div class="col-12"> <div class="col-12">
<h4>Author{{ publication.authors.all|length|pluralize }} and Organization{{ affiliations_list|length|pluralize }} links</h4> <h4>Author{{ publication.authors.all|length|pluralize }} and Organization{{ affiliations_list|length|pluralize }} links</h4>
<ul class="list-inline"> <ul class="list-inline">
{% for author in publication.authors.all %} {% for author in publication.authors.all %}
<li class="list-inline-item"> <li class="list-inline-item">
{% for aff in affiliations_list %}
{% if aff in author.affiliations.all %}
<sup>{{ forloop.counter }} </sup>
{% endif %}{% endfor %}
{% if author.is_registered %}
<a href="{{ author.contributor.get_absolute_url }}">{{ author.contributor.user.first_name }} {{ author.contributor.user.last_name }}</a>
{% else %}
{{ author.unregistered_author.first_name }} {{ author.unregistered_author.last_name }}
{% endif %}
</li>
{% if not forloop.last %}, {% endif %}
{% endfor %}
</ul>
<ul class="list list-unstyled">
{% for aff in affiliations_list %} {% for aff in affiliations_list %}
<li><sup>{{ forloop.counter }}</sup>&nbsp;<a href="{{ aff.get_absolute_url }}">{{ aff.name_full }}</a></li> {% if aff in author.affiliations.all %}
{% endfor %} <sup>{{ forloop.counter }} </sup>
</ul> {% endif %}{% endfor %}
{% if author.is_registered %}
{% if publication.get_all_funders %} <a href="{{ author.contributor.get_absolute_url }}">{{ author.contributor.user.first_name }} {{ author.contributor.user.last_name }}</a>
<h4>Funder{{ publication.get_all_funders|length|pluralize }} for the research work leading to this publication</h4> {% else %}
<ul> {{ author.unregistered_author.first_name }} {{ author.unregistered_author.last_name }}
{% for funder in publication.get_all_funders %} {% endif %}
<li><a href="{{ funder.get_absolute_url }}">{{ funder }}</a></li> </li>
{% endfor %} {% if not forloop.last %}, {% endif %}
</ul> {% endfor %}
{% endif %} </ul>
{% if is_scipost_admin or is_edcol_admin %} <ul class="list list-unstyled">
{% if publication.institutions.all %} {% for aff in affiliations_list %}
<h4>Institution{{ publication.institutions.all|pluralize }} related to this Publication (<span class="text-danger">Admin-only view, to be removed</span>)</h4> <li><sup>{{ forloop.counter }}</sup>&nbsp;<a href="{{ aff.get_absolute_url }}">{{ aff.name_full }}</a></li>
<ul> {% endfor %}
{% for institution in publication.institutions.all %} </ul>
<li><a href="{{ institution.get_absolute_url }}">{{ institution }}</a></li>
{% endfor %} {% if publication.get_all_funders %}
</ul> <h4>Funder{{ publication.get_all_funders|length|pluralize }} for the research work leading to this publication</h4>
{% endif %} <ul>
{% endif %} {% for funder in publication.get_all_funders %}
<li><a href="{{ funder.get_absolute_url }}">{{ funder }}</a></li>
{% endfor %}
</ul>
{% endif %}
{% if is_scipost_admin or is_edcol_admin %}
{% if publication.institutions.all %}
<h4>Institution{{ publication.institutions.all|pluralize }} related to this Publication (<span class="text-danger">Admin-only view, to be removed</span>)</h4>
<ul>
{% for institution in publication.institutions.all %}
<li><a href="{{ institution.get_absolute_url }}">{{ institution }}</a></li>
{% endfor %}
</ul>
{% endif %}
{% endif %}
</div> </div>
</div> </div>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment