SciPost Code Repository

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

Improve display of pubfractions

parent 17f904c5
No related branches found
No related tags found
No related merge requests found
...@@ -105,6 +105,17 @@ class Organization(models.Model): ...@@ -105,6 +105,17 @@ class Organization(models.Model):
self.cf_nr_associated_publications = self.count_publications() self.cf_nr_associated_publications = self.count_publications()
self.save() self.save()
def pubfraction_for_publication(self, doi_label):
"""
Return the organization's pubfraction for this publication, or the string 'Not defined'.
"""
try:
return OrgPubFraction.objects.get(
organization=self,
publication__doi_label=doi_label).fraction
except:
return 'Not yet defined'
def pubfractions_in_year(self, year): def pubfractions_in_year(self, year):
""" """
Returns the sum of pubfractions for the given year. Returns the sum of pubfractions for the given year.
......
...@@ -60,6 +60,9 @@ $(document).ready(function($) { ...@@ -60,6 +60,9 @@ $(document).ready(function($) {
<a href="{{ publication.get_absolute_url }}">{{ publication.title }}</a> <a href="{{ publication.get_absolute_url }}">{{ publication.title }}</a>
<br>by {{ publication.author_list }}, <br>by {{ publication.author_list }},
<br>{{ publication.citation }} <br>{{ publication.citation }}
{% if is_scipost_admin %}
<br><span class="text-muted small">Pubfraction: {{ org|pubfraction_for_publication:publication }}</span>
{% endif %}
</li> </li>
{% endif %} {% endif %}
{% endfor %} {% endfor %}
......
...@@ -7,6 +7,10 @@ from django import template ...@@ -7,6 +7,10 @@ from django import template
register = template.Library() register = template.Library()
@register.filter(name='pubfraction_for_publication')
def pubfraction_for_publication(org, publication):
return org.pubfraction_for_publication(publication.doi_label)
@register.filter(name='pubfractions_in_year') @register.filter(name='pubfractions_in_year')
def pubfractions_in_year(org, year): def pubfractions_in_year(org, year):
return org.pubfractions_in_year(int(year)) return org.pubfractions_in_year(int(year))
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