From 2678e0ad5a22afd06424e050a8b00c26ec4e4ec7 Mon Sep 17 00:00:00 2001 From: Jorran de Wit <jorrandewit@outlook.com> Date: Fri, 17 Nov 2017 23:26:31 +0100 Subject: [PATCH] Make easy linking to Funder page --- funders/models.py | 4 ++++ funders/templates/funders/funder_details.html | 2 -- funders/urls.py | 4 ++-- funders/views.py | 4 ++-- .../journals/publication_detail.html | 24 ++++++++++++++----- 5 files changed, 26 insertions(+), 12 deletions(-) diff --git a/funders/models.py b/funders/models.py index 5ef9a4119..828d275f9 100644 --- a/funders/models.py +++ b/funders/models.py @@ -1,5 +1,6 @@ from django.db import models from django.db.models import Q +from django.urls import reverse from journals.models import Publication @@ -22,6 +23,9 @@ class Funder(models.Model): result += ' (%s)' % self.acronym return result + def get_absolute_url(self): + return reverse('funders:funder_publications', args=(self.id,)) + def all_related_publications(self): return Publication.objects.filter( Q(funders_generic=self) | Q(grants__funder=self)).distinct() diff --git a/funders/templates/funders/funder_details.html b/funders/templates/funders/funder_details.html index cbb873263..382cb69bb 100644 --- a/funders/templates/funders/funder_details.html +++ b/funders/templates/funders/funder_details.html @@ -2,8 +2,6 @@ {% block pagetitle %}: Funder details{% endblock pagetitle %} -{% load bootstrap %} - {% block content %} <h1 class="highlight">Funder {{ funder.name }}</h1> diff --git a/funders/urls.py b/funders/urls.py index b424202a9..6766a095b 100644 --- a/funders/urls.py +++ b/funders/urls.py @@ -6,8 +6,8 @@ urlpatterns = [ url(r'^$', views.funders, name='funders'), url(r'^query_crossref_for_funder$', views.query_crossref_for_funder, name='query_crossref_for_funder'), - url(r'^funders/add$', views.add_funder, name='add_funder'), - url(r'^funders/(?P<funder_id>[0-9]+)/$', views.funder_publications, + url(r'^add$', views.add_funder, name='add_funder'), + url(r'^(?P<funder_id>[0-9]+)/$', views.funder_publications, name='funder_publications'), url(r'^grants/add$', views.add_grant, name='add_grant'), ] diff --git a/funders/views.py b/funders/views.py index 1b3d3b8c2..b11b7a15b 100644 --- a/funders/views.py +++ b/funders/views.py @@ -53,10 +53,10 @@ def add_funder(request): return redirect(reverse('funders:funders')) -@permission_required('scipost.can_view_all_funding_info', raise_exception=True) +# @permission_required('scipost.can_view_all_funding_info', raise_exception=True) def funder_publications(request, funder_id): """ - See details of specific Funder. + See details of specific Funder (publicly accessible). """ funder = get_object_or_404(Funder, id=funder_id) context = {'funder': funder} diff --git a/journals/templates/journals/publication_detail.html b/journals/templates/journals/publication_detail.html index 911fcf398..a02fa03f8 100644 --- a/journals/templates/journals/publication_detail.html +++ b/journals/templates/journals/publication_detail.html @@ -97,12 +97,24 @@ {% if is_edcol_admin %} {# This function is not available for public yet! #} - <h3>Institutions related to this Publication: <small>(adminstrator only)</small></h3> - <ul> - {% for institution in publication.institutions.all %} - <li>{{ institution }}</li> - {% endfor %} - </ul> + <em>The following is not available for the public yet:</em> + {% if publication.funders_generic.exists %} + <h3>Funder{{ publication.funders_generic.count|pluralize }} for this publication:</h3> + <ul> + {% for funder in publication.funders_generic.all %} + <li><a href="{{ funder.get_absolute_url }}">{{ funder }}</a></li> + {% endfor %} + </ul> + {% endif %} + + {% if publication.institutions.exists %} + <h3>Institution{{ publication.institutions.count|pluralize }} related to this Publication:</h3> + <ul> + {% for institution in publication.institutions.all %} + <li>{{ institution }}</li> + {% endfor %} + </ul> + {% endif %} {% endif %} </div> </div> -- GitLab