diff --git a/journals/migrations/0024_publication_lastest_citedby_update.py b/journals/migrations/0024_publication_lastest_citedby_update.py new file mode 100644 index 0000000000000000000000000000000000000000..30f8841d41373a0e252f990b4cfd9609a3c969cb --- /dev/null +++ b/journals/migrations/0024_publication_lastest_citedby_update.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.3 on 2017-07-08 09:07 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('journals', '0023_auto_20170517_1846'), + ] + + operations = [ + migrations.AddField( + model_name='publication', + name='lastest_citedby_update', + field=models.DateTimeField(blank=True, null=True), + ), + ] diff --git a/journals/models.py b/journals/models.py index 920371b7819b43ae6d49c9e35619b65cd36c1ab0..7276e6ef706782ce6ad211656ecdbeb5f847f9a5 100644 --- a/journals/models.py +++ b/journals/models.py @@ -148,6 +148,7 @@ class Publication(models.Model): submission_date = models.DateField(verbose_name='submission date') acceptance_date = models.DateField(verbose_name='acceptance date') publication_date = models.DateField(verbose_name='publication date') + lastest_citedby_update = models.DateTimeField(null=True, blank=True) latest_activity = models.DateTimeField(default=timezone.now) citedby = JSONField(default={}, blank=True, null=True) diff --git a/journals/templates/journals/harvest_citedby_list.html b/journals/templates/journals/harvest_citedby_list.html new file mode 100644 index 0000000000000000000000000000000000000000..cc51d57af8aafdc5890aa98d067444d54f4fae74 --- /dev/null +++ b/journals/templates/journals/harvest_citedby_list.html @@ -0,0 +1,60 @@ +{% extends 'scipost/_personal_page_base.html' %} + +{% block pagetitle %}: Harvest citedby data{% endblock pagetitle %} + +{% load bootstrap %} + +{% block breadcrumb_items %} + {{block.super}} + <span class="breadcrumb-item">Harvest citedby data</span> +{% endblock %} + +{% block content %} + +<div class="row"> + <div class="col-12"> + <h1 class="highlight">Harvest citedby data</h1> + </div> +</div> + +<div class="row"> + <div class="col-12"> + <table class="table"> + <thead> + <tr> + <th>doi</th> + <th>Publication date</th> + <th>Lastest Crossref update</th> + <th>Actions</th> + </tr> + </thead> + <tbody> + {% for publication in publications %} + <tr> + <td><a href="{{publication.get_absolute_url}}">{{publication.doi_label}}</a></td> + <td>{{publication.publication_date}}</td> + <td> + {% if publication.lastest_citedby_update %} + {{publication.lastest_citedby_update|timesince}} ago + {% else %} + No information available + {% endif %} + </td> + <td> + <ul> + <li><a href="{% url 'journals:harvest_citedby_links' publication.doi_label %}">Harvest citedby data now</a></li> + </ul> + </td> + </tr> + {% empty %} + <tr> + <td colspan="5">No publications found.</td> + </tr> + {% endfor %} + </tbody> + </table> + </div> +</div> + + +{% endblock content %} diff --git a/journals/urls/general.py b/journals/urls/general.py index 76d8ab0b758416a861fe8b654cdd747bb3c4b7be..371c1184740b9b533603cd31a3be1e901db8797f 100644 --- a/journals/urls/general.py +++ b/journals/urls/general.py @@ -49,6 +49,9 @@ urlpatterns = [ url(r'^metadata_xml_deposit/(?P<doi_label>[a-zA-Z]+.[0-9]+.[0-9]+.[0-9]{3,})/(?P<option>[a-z]+)$', journals_views.metadata_xml_deposit, name='metadata_xml_deposit'), + url(r'^harvest_citedby_links/$', + journals_views.harvest_all_publications, + name='harvest_all_publications'), url(r'^harvest_citedby_links/(?P<doi_label>[a-zA-Z]+.[0-9]+.[0-9]+.[0-9]{3,})$', journals_views.harvest_citedby_links, name='harvest_citedby_links'), diff --git a/journals/views.py b/journals/views.py index c901e579b419c757e395de4d9054f3b1ef467a33..96fcf194e86aa1ac05876ee6a31222b52ab1adce 100644 --- a/journals/views.py +++ b/journals/views.py @@ -601,6 +601,15 @@ def metadata_xml_deposit(request, doi_label, option='test'): return render(request, 'journals/metadata_xml_deposit.html', context) +@permission_required('scipost.can_publish_accepted_submission', return_403=True) +def harvest_all_publications(request): + publications = Publication.objects.order_by('-lastest_citedby_update', '-publication_date') + context = { + 'publications': publications + } + return render(request, 'journals/harvest_citedby_list.html', context) + + @permission_required('scipost.can_publish_accepted_submission', return_403=True) @transaction.atomic def harvest_citedby_links(request, doi_label): @@ -637,7 +646,7 @@ def harvest_citedby_links(request, doi_label): if r.status_code == 401: messages.warning(request, ('<h3>Crossref credentials are invalid.</h3>' 'Please contact the SciPost Admin.')) - return redirect(publication.get_absolute_url()) + return redirect(reverse('journals:harvest_all_publications')) response_headers = r.headers response_text = r.text response_deserialized = ET.fromstring(r.text) @@ -680,6 +689,7 @@ def harvest_citedby_links(request, doi_label): 'item_number': item_number, 'year': year, }) publication.citedby = citations + publication.lastest_citedby_update = timezone.now() publication.save() context = { 'publication': publication, diff --git a/scipost/templates/scipost/personal_page.html b/scipost/templates/scipost/personal_page.html index 10485656d0002f7454cde5e7ea1622550195c7aa..9d15e8e6a04dd51f68c227ee100def28af118e6d 100644 --- a/scipost/templates/scipost/personal_page.html +++ b/scipost/templates/scipost/personal_page.html @@ -263,6 +263,15 @@ {% endif %} </ul> + {% if 'Editorial Administrators' in user_groups %} + <h3>Editorial Admin actions</h3> + <ul> + {% if perms.scipost.can_publish_accepted_submission %} + <li><a href="{% url 'journals:harvest_all_publications' %}">Harvest citedby data</a></li> + {% endif %} + </ul> + {% endif %} + {% if perms.scipost.can_attend_VGMs %} <h3>Virtual General Meetings</h3> <ul>