SciPost Code Repository

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

Merge branch 'dev_JSC_20220223_IPR' into dev_JSC_20220220_orglogos

parents cf03d963 e9b5091b
No related branches found
No related tags found
No related merge requests found
# Generated by Django 3.2.12 on 2022-02-23 15:06
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('affiliates', '0007_alter_affiliatepublication__metadata_crossref'),
]
operations = [
migrations.AddField(
model_name='affiliatejournal',
name='homepage',
field=models.URLField(blank=True, max_length=256),
),
]
......@@ -30,6 +30,8 @@ class AffiliateJournal(models.Model):
unique=True,
)
homepage = models.URLField(max_length=256, blank=True)
class Meta:
ordering = ["publisher", "name"]
permissions = (("manage_journal_content", "Manage Journal content"),)
......
......@@ -57,6 +57,9 @@ class AffiliatePublication(models.Model):
def get_volume(self):
return self._metadata_crossref.get("volume", "")
def get_issue(self):
return self._metadata_crossref.get("issue", "")
def get_pages(self):
pages = self._metadata_crossref.get("article-number", "")
if not pages:
......
......@@ -21,10 +21,13 @@
<br>
by {{ pub.get_author_list }}
<br>
{{ pub.journal }}
<em>{{ pub.journal }}</em>
{% if pub.get_volume %}
&nbsp;Vol. {{ pub.get_volume }}
{% endif %}
{% if pub.get_issue %}
&nbsp;({{ pub.get_issue }})
{% endif %}
{% if pub.get_pages %}
,&nbsp;p.{{ pub.get_pages }}
{% endif %}
......
......@@ -18,72 +18,128 @@
<h2 class="highlight">Affiliate Journal: {{ object }}</h2>
<div class="row p-2">
<div class="col">
<h3>Journal information</h3>
<table class="table">
<tr>
<th>Homepage</th>
<td>{% if object.homepage %}<a href="{{ object.homepage }}" target="_blank">{{ object.homepage }}&nbsp;{% include 'bi/box-arrow-up-right.html' %}</a>{% else %}(not defined){% endif %}</td>
</tr>
</table>
</div>
</div>
{% if perms.affiliates.can_edit_affiliatedjournal %}
<h3 class="highlight">Journal managers</h3>
<div class="row p-2">
<div class="col-lg-6">
<h4>Add manager</h4>
<form action="{% url 'affiliates:journal_add_manager' slug=object.slug %}" method="post">
{% csrf_token %}
{{ add_manager_form }}
<input type="submit" value="Submit" class="btn btn-primary">
</form>
</div>
<div class="col-lg-6">
<h4>Current list of managers</h4>
<ul>
{% for manager in journal_managers.all %}
<li>{{ manager.last_name }}, {{ manager.first_name }}&emsp;
<a href="{% url 'affiliates:journal_remove_manager' slug=object.slug user_id=manager.pk %}">
<span class="text-danger">{% include 'bi/x-square-fill.html' %}</span>
</a>
</li>
{% empty %}
<li>No managers found</li>
{% endfor %}
</ul>
<div class="col">
<div class="border border-danger mb-2 p-2">
<strong class="text-danger">Administration</strong>
<h3 class="highlight">Journal managers</h3>
<div class="row p-2">
<div class="col-lg-6">
<h4>Add manager</h4>
<form action="{% url 'affiliates:journal_add_manager' slug=object.slug %}" method="post">
{% csrf_token %}
{{ add_manager_form }}
<input type="submit" value="Submit" class="btn btn-primary">
</form>
</div>
<div class="col-lg-6">
<h4>Current list of managers</h4>
<ul>
{% for manager in journal_managers.all %}
<li>{{ manager.last_name }}, {{ manager.first_name }}&emsp;
<a href="{% url 'affiliates:journal_remove_manager' slug=object.slug user_id=manager.pk %}">
<span class="text-danger">{% include 'bi/x-square-fill.html' %}</span>
</a>
</li>
{% empty %}
<li>No managers found</li>
{% endfor %}
</ul>
</div>
</div>
</div>
</div>
</div>
{% endif %}
<h3 class="highlight">Publications</h3>
<div class="row p-2">
{% if perms.affiliates.can_edit_affiliatedjournal %}
<div class="col">
<h4>Update publications from Crossref</h4>
<a class="btn btn-primary" href="{% url 'affiliates:journal_update_publications_from_Crossref' slug=object.slug %}">Run full update</a>
</div>
{% endif %}
{% if 'manage_journal_content' in user_perms %}
<div class="col">
<h4>Add a publication</h4>
<form action="{% url 'affiliates:journal_add_publication' slug=object.slug %}" method="post">
{% csrf_token %}
{{ add_publication_form }}
<input type="submit" value="Submit" class="btn btn-primary">
</form>
</div>
{% endif %}
</div>
{% if perms.affiliates.can_edit_affiliatedjournal %}
<div class="row p-2">
<div class="col">
<h4>Recent publications <small>(ten most recent)</small>
&emsp;
<a class="btn btn-sm btn-primary" href="{% url 'affiliates:publication_list' %}?journal={{ object.slug }}">
{% include 'bi/arrow-right.html' %}&nbsp;View all publications in this Journal</a>
</h4>
{% if 'manage_journal_content' in user_perms %}
{% include 'affiliates/_affiliatepublication_table.html' with publications=object.publications.all|slice:":10" can_manage_journal_content=True %}
{% else %}
{% include 'affiliates/_affiliatepublication_table.html' with publications=object.publications.all|slice:":10" %}
{% endif %}
<div class="border border-danger mb-2 p-2">
<strong class="text-danger">Administration</strong>
<h4>Update publications from Crossref</h4>
<a class="btn btn-primary" href="{% url 'affiliates:journal_update_publications_from_Crossref' slug=object.slug %}">Run full update</a>
</div>
</div>
</div>
<h3 class="highlight">Benefitting Organizations</h3>
{% endif %}
{% if 'manage_journal_content' in user_perms %}
<div class="row p-2">
<div class="col">
<a class="btn btn-sm btn-primary" href="{% url 'affiliates:journal_organizations' slug=object.slug %}">
{% include 'bi/arrow-right.html' %}&nbsp;View all benefitting Organizations</a>
<div class="border border-warning mb-2 p-2">
<strong class="text-warning">Management</strong>
<h4>Add a publication</h4>
<form action="{% url 'affiliates:journal_add_publication' slug=object.slug %}" method="post">
{% csrf_token %}
{{ add_publication_form }}
<input type="submit" value="Submit" class="btn btn-primary">
</form>
</div>
</div>
</div>
{% endif %}
<div class="row p-2">
<div class="col">
<h3 class="highlight">Recent publications <small>(ten most recent)</small>
<a class="btn btn-sm btn-primary ms-5" href="{% url 'affiliates:publication_list' %}?journal={{ object.slug }}">
{% include 'bi/arrow-right.html' %}View all publications in this Journal</a>
</h3>
{% if 'manage_journal_content' in user_perms %}
{% include 'affiliates/_affiliatepublication_table.html' with publications=object.publications.all|slice:":10" can_manage_journal_content=True %}
{% else %}
{% include 'affiliates/_affiliatepublication_table.html' with publications=object.publications.all|slice:":10" %}
{% endif %}
</div>
</div>
<div class="row p-2">
<div class="col">
<h3 class="highlight">Benefitting Organizations <small>(ten most prominent)</small>
<a class="btn btn-sm btn-primary ms-5" href="{% url 'affiliates:journal_organizations' slug=object.slug %}">
{% include 'bi/arrow-right.html' %}&nbsp;View all benefitting Organizations</a>
</h3>
<table class="table">
<thead>
<tr>
<th>Organization</th>
<th>Summed<br>PubFractions</th>
</tr>
</thead>
<tbody>
{% for organization in top_benefitting_organizations %}
<tr>
<td>
<a href="{% url 'organizations:organization_detail' pk=organization.id %}">{{ organization }}</a>
</td>
<td>{{ organization.sum_affiliate_pubfractions }}</td>
</tr>
{% empty %}
<tr>
<td>No items at this time</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
{% endblock content %}
......
......@@ -11,20 +11,19 @@
{% block content %}
<h2 class="highlight">{{ journal }}: benefitting Organizations</h2>
<h2 class="highlight">{{ journal }}: Benefitting Organizations</h2>
<table class="table">
<thead>
<tr>
<th>Country</th>
<th>Organization</th>
<th>Country</th>
<th>Summed<br>PubFractions</th>
</tr>
</thead>
<tbody>
{% for organization in object_list %}
<tr>
<td><img src="{{ organization.country.flag }}" alt="{{ organization.country }} flag"/>&nbsp;<span class="text-muted"><small>[{{ organization.country }}]</small></span>&nbsp;&nbsp;{{ organization.get_country_display }}</td>
<td>
<a href="{% url 'organizations:organization_detail' pk=organization.id %}">{{ organization }}</a>
{% if organization.parent %}
......@@ -42,6 +41,7 @@
<p><small class="text-muted">Superseded by {{ organization.superseded_by }}</small></p>
{% endif %}
</td>
<td><img src="{{ organization.country.flag }}" alt="{{ organization.country }} flag"/>&nbsp;<span class="text-muted"><small>[{{ organization.country }}]</small></span>&nbsp;&nbsp;{{ organization.get_country_display }}</td>
<td>{{ organization.sum_affiliate_pubfractions }}</td>
</tr>
{% empty %}
......@@ -52,4 +52,10 @@
</tbody>
</table>
{% if is_paginated %}
<div class="col-12">
{% include '_pagination.html' with page_obj=page_obj %}
</div>
{% endif %}
{% endblock content %}
......@@ -27,8 +27,10 @@
<table class="table">
<tr><td><strong>Title</strong></td><td>{{ object.get_title }}</td></tr>
<tr><td><strong>Author list</strong></td><td>{{ object.get_author_list }}</td></tr>
<tr><td><strong>Volume</strong></td><td>{{ object.get_volume }}</td></tr>
<tr><td><strong>Pages</strong></td><td>{{ object.get_pages }}</td></tr>
<tr><td><strong>Volume</strong></td><td>{{ object.get_volume }}{% if object.get_issue %}&nbsp;({{ object.get_issue}}){% endif %}</td></tr>
{% if object.get_pages %}
<tr><td><strong>Pages</strong></td><td>{{ object.get_pages }}</td></tr>
{% endif %}
<tr><td><strong>Publication date</strong></td><td>{{ object.publication_date }}</td></tr>
<tr><td><strong>DOI</strong></td><td><a href="https://doi.org/{{ object.doi }}" rel="nofollow" target="_blank">{{ object.doi }}</a></td></tr>
</table>
......
......@@ -41,6 +41,21 @@ class AffiliateJournalDetailView(DetailView):
context["add_publication_form"] = AffiliateJournalAddPublicationForm(
initial={"journal": self.object}
)
# Get top 5 benefitting Organizations
pubfractions = AffiliatePubFraction.objects.filter(
publication__journal=self.object,
)
organization_id_list = set([p.organization.id for p in pubfractions.all()])
organizations = Organization.objects.filter(
id__in=organization_id_list
).distinct()
organizations = organizations.annotate(
sum_affiliate_pubfractions=Sum(
"affiliate_pubfractions__fraction",
filter=Q(affiliate_pubfractions__publication__journal=self.object),
)
).order_by("-sum_affiliate_pubfractions")
context["top_benefitting_organizations"] = organizations[:10]
return context
......@@ -89,7 +104,7 @@ def affiliatejournal_update_publications_from_Crossref(request, slug):
class AffiliatePublicationListView(PaginationMixin, ListView):
paginate_by = 10
paginate_by = 25
class Meta:
model = AffiliatePublication
......@@ -145,6 +160,7 @@ def delete_pubfraction(request, slug, doi, pubfrac_id):
class AffiliateJournalOrganizationListView(PaginationMixin, ListView):
template_name = "affiliates/affiliatejournal_organization_list.html"
paginate_by = 25
class Meta:
model = Organization
......@@ -153,7 +169,7 @@ class AffiliateJournalOrganizationListView(PaginationMixin, ListView):
# First, get all the relevant AffiliatePubFractions
journal = get_object_or_404(AffiliateJournal, slug=self.kwargs["slug"])
pubfractions = AffiliatePubFraction.objects.filter(publication__journal=journal)
organization_id_list = [p.organization.id for p in pubfractions.all()]
organization_id_list = set([p.organization.id for p in pubfractions.all()])
organizations = Organization.objects.filter(
id__in=organization_id_list
).distinct()
......
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-box-arrow-up-right" viewBox="0 0 16 16">
<path fill-rule="evenodd" d="M8.636 3.5a.5.5 0 0 0-.5-.5H1.5A1.5 1.5 0 0 0 0 4.5v10A1.5 1.5 0 0 0 1.5 16h10a1.5 1.5 0 0 0 1.5-1.5V7.864a.5.5 0 0 0-1 0V14.5a.5.5 0 0 1-.5.5h-10a.5.5 0 0 1-.5-.5v-10a.5.5 0 0 1 .5-.5h6.636a.5.5 0 0 0 .5-.5z"/>
<path fill-rule="evenodd" d="M16 .5a.5.5 0 0 0-.5-.5h-5a.5.5 0 0 0 0 1h3.793L6.146 9.146a.5.5 0 1 0 .708.708L15 1.707V5.5a.5.5 0 0 0 1 0v-5z"/>
</svg>
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