SciPost Code Repository

Skip to content
Snippets Groups Projects
Commit 2678e0ad authored by Jorran de Wit's avatar Jorran de Wit
Browse files

Make easy linking to Funder page

parent 62e7c586
No related branches found
No related tags found
No related merge requests found
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()
......
......@@ -2,8 +2,6 @@
{% block pagetitle %}: Funder details{% endblock pagetitle %}
{% load bootstrap %}
{% block content %}
<h1 class="highlight">Funder {{ funder.name }}</h1>
......
......@@ -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'),
]
......@@ -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}
......
......@@ -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>
......
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