diff --git a/journals/admin.py b/journals/admin.py index 8c82762bbe9cb7df533f9aec127ecb2ca1328fe7..167b0f62e4f1dadb5dcecaff88dc8d128c367ad5 100644 --- a/journals/admin.py +++ b/journals/admin.py @@ -64,7 +64,7 @@ admin.site.register(Publication, PublicationAdmin) class DepositAdmin(admin.ModelAdmin): - list_display = ('doi_batch_id', 'publication', 'deposition_date',) + list_display = ('publication', 'timestamp', 'doi_batch_id', 'deposition_date',) readonly_fields = ('publication', 'doi_batch_id', 'metadata_xml', 'deposition_date',) actions = None 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/migrations/0025_auto_20170708_1154.py b/journals/migrations/0025_auto_20170708_1154.py new file mode 100644 index 0000000000000000000000000000000000000000..3290f9071eace79f55ca044d85bb776511f0a1f2 --- /dev/null +++ b/journals/migrations/0025_auto_20170708_1154.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.3 on 2017-07-08 09:54 +from __future__ import unicode_literals + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('journals', '0024_publication_lastest_citedby_update'), + ] + + operations = [ + migrations.RenameField( + model_name='publication', + old_name='lastest_citedby_update', + new_name='latest_citedby_update', + ), + ] diff --git a/journals/migrations/0026_auto_20170708_1542.py b/journals/migrations/0026_auto_20170708_1542.py new file mode 100644 index 0000000000000000000000000000000000000000..7a78e36a6d46a1237959a862edd9004f1f2dd400 --- /dev/null +++ b/journals/migrations/0026_auto_20170708_1542.py @@ -0,0 +1,30 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.3 on 2017-07-08 13:42 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('journals', '0025_auto_20170708_1154'), + ] + + operations = [ + migrations.AddField( + model_name='publication', + name='latest_crossref_deposit', + field=models.DateTimeField(blank=True, null=True), + ), + migrations.AddField( + model_name='publication', + name='latest_metadata_update', + field=models.DateTimeField(blank=True, null=True), + ), + migrations.AddField( + model_name='publication', + name='metadata_xml_file', + field=models.FileField(blank=True, null=True, upload_to=''), + ), + ] diff --git a/journals/migrations/0027_auto_20170710_0805.py b/journals/migrations/0027_auto_20170710_0805.py new file mode 100644 index 0000000000000000000000000000000000000000..cce57940d89031f9061d97c21fb1f0665f18708b --- /dev/null +++ b/journals/migrations/0027_auto_20170710_0805.py @@ -0,0 +1,39 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.3 on 2017-07-10 06:05 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('journals', '0026_auto_20170708_1542'), + ] + + operations = [ + migrations.RemoveField( + model_name='publication', + name='metadata_xml_file', + ), + migrations.AddField( + model_name='deposit', + name='metadata_xml_file', + field=models.FileField(blank=True, null=True, upload_to=''), + ), + migrations.AddField( + model_name='deposit', + name='response_text', + field=models.TextField(blank=True, null=True), + ), + migrations.AddField( + model_name='deposit', + name='timestamp', + field=models.CharField(default='', max_length=40), + ), + migrations.AlterField( + model_name='deposit', + name='deposition_date', + field=models.DateTimeField(blank=True, null=True), + ), + ] diff --git a/journals/migrations/0028_auto_20170710_0906.py b/journals/migrations/0028_auto_20170710_0906.py new file mode 100644 index 0000000000000000000000000000000000000000..4c0d934848fa8d9ac001e5b72ea3cd1ae6c2f05d --- /dev/null +++ b/journals/migrations/0028_auto_20170710_0906.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.3 on 2017-07-10 07:06 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('journals', '0027_auto_20170710_0805'), + ] + + operations = [ + migrations.AlterModelOptions( + name='deposit', + options={'ordering': ['-timestamp']}, + ), + migrations.AddField( + model_name='deposit', + name='deposit_successful', + field=models.NullBooleanField(default=None), + ), + ] diff --git a/journals/migrations/0029_remove_publication_latest_crossref_deposit.py b/journals/migrations/0029_remove_publication_latest_crossref_deposit.py new file mode 100644 index 0000000000000000000000000000000000000000..b6c26989d2fa96aad2a3e3e93445045f151e3ec3 --- /dev/null +++ b/journals/migrations/0029_remove_publication_latest_crossref_deposit.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.3 on 2017-07-10 07:49 +from __future__ import unicode_literals + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('journals', '0028_auto_20170710_0906'), + ] + + operations = [ + migrations.RemoveField( + model_name='publication', + name='latest_crossref_deposit', + ), + ] diff --git a/journals/migrations/0030_auto_20170710_1051.py b/journals/migrations/0030_auto_20170710_1051.py new file mode 100644 index 0000000000000000000000000000000000000000..e3534b85137c5ab4ea9c4dfe140c16ce59aeff28 --- /dev/null +++ b/journals/migrations/0030_auto_20170710_1051.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.3 on 2017-07-10 08:51 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('journals', '0029_remove_publication_latest_crossref_deposit'), + ] + + operations = [ + migrations.AlterField( + model_name='deposit', + name='metadata_xml_file', + field=models.FileField(blank=True, max_length=512, null=True, upload_to=''), + ), + ] diff --git a/journals/models.py b/journals/models.py index 920371b7819b43ae6d49c9e35619b65cd36c1ab0..3f5454a8f8edf552449f05324e644d8d6cac8718 100644 --- a/journals/models.py +++ b/journals/models.py @@ -142,12 +142,14 @@ class Publication(models.Model): pdf_file = models.FileField(upload_to='UPLOADS/PUBLICATIONS/%Y/%m/', max_length=200) metadata = JSONField(default={}, blank=True, null=True) metadata_xml = models.TextField(blank=True, null=True) # for Crossref deposit + latest_metadata_update = models.DateTimeField(blank=True, null=True) BiBTeX_entry = models.TextField(blank=True, null=True) doi_label = models.CharField(max_length=200, unique=True, db_index=True, validators=[doi_publication_validator]) submission_date = models.DateField(verbose_name='submission date') acceptance_date = models.DateField(verbose_name='acceptance date') publication_date = models.DateField(verbose_name='publication date') + latest_citedby_update = models.DateTimeField(null=True, blank=True) latest_activity = models.DateTimeField(default=timezone.now) citedby = JSONField(default={}, blank=True, null=True) @@ -211,6 +213,7 @@ class Publication(models.Model): return template.render(context) + class Deposit(models.Model): """ Each time a Crossref deposit is made for a Publication, @@ -219,9 +222,16 @@ class Deposit(models.Model): All deposit history is thus contained here. """ publication = models.ForeignKey(Publication, on_delete=models.CASCADE) + timestamp = models.CharField(max_length=40, default='') doi_batch_id = models.CharField(max_length=40, default='') metadata_xml = models.TextField(blank=True, null=True) - deposition_date = models.DateTimeField(default=timezone.now) + metadata_xml_file = models.FileField(blank=True, null=True, max_length=512) + deposition_date = models.DateTimeField(blank=True, null=True) + response_text = models.TextField(blank=True, null=True) + deposit_successful = models.NullBooleanField(default=None) + + class Meta: + ordering = ['-timestamp'] def __str__(self): return (self.deposition_date.strftime('%Y-%m-%D') + diff --git a/journals/templates/journals/add_author.html b/journals/templates/journals/add_author.html index 977eaff19441cafbba2bc48b695399f819f4cdc2..1be0c6ec70ab651b7199a365944bf59fa65046de 100644 --- a/journals/templates/journals/add_author.html +++ b/journals/templates/journals/add_author.html @@ -94,7 +94,7 @@ </div> <h3> - <a href="{{publication.get_absolute_url}}">Return to the publication's page</a> + <a href="{{publication.get_absolute_url}}">Return to the publication's page</a> or to the <a href="{% url 'journals:manage_metadata' %}">metadata management page</a> </h3> </div> </div> diff --git a/journals/templates/journals/create_citation_list_metadata.html b/journals/templates/journals/create_citation_list_metadata.html index 037452a969156d6ed46ce3ec382531b43babf06a..a7d68067d8aeede3f8971ebc9c706923f097c72e 100644 --- a/journals/templates/journals/create_citation_list_metadata.html +++ b/journals/templates/journals/create_citation_list_metadata.html @@ -33,7 +33,7 @@ <hr class="hr6"/> - <h3>Once you're happy with this metadata, you can <a href="{{publication.get_absolute_url}}">return to the publication's page</a></h3> + <h3>Once you're happy with this metadata, you can <a href="{{publication.get_absolute_url}}">return to the publication's page</a> or to the <a href="{% url 'journals:manage_metadata' %}">metadata management page</a></h3> </section> diff --git a/journals/templates/journals/create_funding_info_metadata.html b/journals/templates/journals/create_funding_info_metadata.html index 5c953dd55e919990876bdbad2dfa86ed3ea86efd..7e918a563af0236bd0ce89cc15ae7fdd832c8d60 100644 --- a/journals/templates/journals/create_funding_info_metadata.html +++ b/journals/templates/journals/create_funding_info_metadata.html @@ -27,7 +27,7 @@ <hr class="hr6"/> - <h3>Once you're happy with this metadata, you can <a href="{{publication.get_absolute_url}}">return to the publication's page</a></h3> + <h3>Once you're happy with this metadata, you can <a href="{{publication.get_absolute_url}}">return to the publication's page</a> or to the <a href="{% url 'journals:manage_metadata' %}">metadata management page</a></h3> </section> diff --git a/journals/templates/journals/create_metadata_xml.html b/journals/templates/journals/create_metadata_xml.html index 3caea010544c52b21d392abdfd87f0f02badd9c1..6fcb9803386abcfba0d9d5996538c6e700ab2db2 100644 --- a/journals/templates/journals/create_metadata_xml.html +++ b/journals/templates/journals/create_metadata_xml.html @@ -27,7 +27,7 @@ <hr class="hr6"/> - <h3>Once you're happy with this metadata, you can <a href="{{publication.get_absolute_url}}">return to the publication's page</a></h3> + <h3>Once you're happy with this metadata, you can <a href="{{publication.get_absolute_url}}">return to the publication's page</a> or to the <a href="{% url 'journals:manage_metadata' %}">metadata management page</a></h3> </section> diff --git a/journals/templates/journals/harvest_citedby_list.html b/journals/templates/journals/harvest_citedby_list.html new file mode 100644 index 0000000000000000000000000000000000000000..85672fe0818c9f207041c252e5e7d0e06e3bd514 --- /dev/null +++ b/journals/templates/journals/harvest_citedby_list.html @@ -0,0 +1,65 @@ +{% 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>Nr citations</th> + <th>Latest Cited-by 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> + {% if publication.latest_citedby_update %} + <td> + {{ publication.citedby|length }} + </td> + <td> + {{ publication.latest_citedby_update }} + </td> + {% else %} + <td>0</td> + <td>No information available</td> + {% endif %} + <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/templates/journals/manage_metadata.html b/journals/templates/journals/manage_metadata.html new file mode 100644 index 0000000000000000000000000000000000000000..2d5ec8c2408bec25d1d633d422a2e865a7dc6f7a --- /dev/null +++ b/journals/templates/journals/manage_metadata.html @@ -0,0 +1,132 @@ +{% extends 'scipost/_personal_page_base.html' %} + +{% block pagetitle %}: Manage metadata{% endblock pagetitle %} + +{% load bootstrap %} + +{% load journals_extras %} + +<script> +$(function() { +$( "#accordion" ).accordion({ +event: "focusin" +}); +}); +</script> + +{% block breadcrumb_items %} + {{block.super}} + <span class="breadcrumb-item">Manage metadata</span> +{% endblock %} + +{% block content %} + +<div class="row"> + <div class="col-12"> + <h1 class="highlight">Manage Publications Metadata</h1> + </div> +</div> + + +<table class="table table-hover mb-5"> + <thead class="thead-default"> + <tr> + <th>doi</th> + <th>Publication date</th> + <th>Latest metadata update</th> + <th>Latest successful Crossref deposit</th> + </tr> + </thead> + + <tbody id="accordion" role="tablist" aria-multiselectable="true"> + {% for publication in publications %} + <tr data-toggle="collapse" data-parent="#accordion" href="#collapse{{ publication.id }}" aria-expanded="true" aria-controls="collapse{{ publication.id }}" style="cursor: pointer;"> + <td><a href="{{ publication.get_absolute_url }}">{{ publication.doi_label }}</a></td> + <td>{{ publication.publication_date }}</td> + {% if publication.latest_metadata_update %} + <td> + {{ publication.latest_metadata_update }} + </td> + {% else %} + <td>No info available</td> + {% endif %} + <td>{{ publication|latest_successful_crossref_deposit }}</td> + </tr> + <tr id="collapse{{ publication.id }}" class="collapse" role="tabpanel" aria-labelledby="heading{{ publication.id }}" style="background-color: #fff;"> + <td colspan="4"> + <h3 class="ml-3">Actions</h3> + <ul> + <li>Mark the first author (currently: {% if publication.first_author %}{{ publication.first_author }} {% elif publication.first_author_unregistered %}{{ publication.first_author_unregistered }} (unregistered){% endif %}) + <div class="row"> + <div class="col-md-5"> + <p>registered authors:</p> + <ul> + {% for author in publication.authors.all %} + <li> + <a href="{% url 'journals:mark_first_author' publication_id=publication.id contributor_id=author.id %}">{{ author }}</a> + </li> + {% endfor %} + </ul> + </div> + <div class="col-md-5"> + <p>unregistered authors:</p> + <ul> + {% for author_unreg in publication.authors_unregistered.all %} + <li> + <a href="{% url 'journals:mark_first_author_unregistered' publication_id=publication.id unregistered_author_id=author_unreg.id %}">{{ author_unreg }}</a> + </li> + {% endfor %} + </ul> + </div> + </div> + </li> + <li><a href="{% url 'journals:add_author' publication.id %}">Add a missing author</a></li> + <li><a href="{% url 'journals:create_citation_list_metadata' publication.doi_label %}">Create/update citation list metadata</a></li> + <li><a href="{% url 'journals:create_funding_info_metadata' publication.doi_label %}">Create/update funding info metadata</a></li> + + <li><a href="{% url 'journals:create_metadata_xml' publication.doi_label %}">(re)create metadata</a></li> + <li><a href="{% url 'journals:metadata_xml_deposit' publication.doi_label 'test' %}">Test metadata deposit (via Crossref test server)</a></li> + <li><a href="{% url 'journals:metadata_xml_deposit' publication.doi_label 'deposit' %}">Deposit the metadata to Crossref</a></li> + </ul> + <h3 class="ml-3">Deposits</h3> + <table class="ml-5"> + <thead class="thead-default"> + <th>Timestamp</th> + <th>batch id</th> + <th>deposition date</th> + <th>Successful?</th> + <th>actions</th> + </thead> + <tbody> + {% for deposit in publication.deposit_set.all %} + <tr> + <td>{{ deposit.timestamp }}</td> + <td>{{ deposit.doi_batch_id }}</td> + <td>{% if deposit.deposition_date %}{{ deposit.deposition_date }}{% else %}Not deposited{% endif %}</td> + <td>{{ deposit.deposit_successful }}</td> + <td>Mark deposit as + <ul> + <li><a href="{% url 'journals:mark_deposit_success' deposit_id=deposit.id success=1 %}">successful</a></li> + <li><a href="{% url 'journals:mark_deposit_success' deposit_id=deposit.id success=0 %}">unsuccessful</a></li> + </ul> + </td> + </tr> + {% empty %} + <tr> + <td colspan="4">No Deposits found for this publication</td> + </tr> + {% endfor %} + </tbody> + </table> + </td> + </tr> + {% empty %} + <tr> + <td colspan="4">No publications found.</td> + </tr> + {% endfor %} + </tbody> +</table> + + +{% endblock content %} diff --git a/journals/templates/journals/metadata_xml_deposit.html b/journals/templates/journals/metadata_xml_deposit.html index bc16e8cc58a40b697bfbac89e9691e310288a04a..645cba7c0b3d86dd2356e729ce5f22c62bcc7956 100644 --- a/journals/templates/journals/metadata_xml_deposit.html +++ b/journals/templates/journals/metadata_xml_deposit.html @@ -22,7 +22,7 @@ <h3>Response text:</h3> <p>{{ response_text|linebreaks }}</p> - <h3><a href="{{publication.get_absolute_url}}">return to the publication's page</a></h3> + <h3><a href="{{publication.get_absolute_url}}">return to the publication's page</a> or to the <a href="{% url 'journals:manage_metadata' %}">metadata management page</a></h3> </section> diff --git a/journals/templatetags/journals_extras.py b/journals/templatetags/journals_extras.py index 382ac91e2b0e6a2528fbd9c54349ca4a9e0ac332..36ca1920715e306fd6e8ed8cccc0caa6ca998747 100644 --- a/journals/templatetags/journals_extras.py +++ b/journals/templatetags/journals_extras.py @@ -8,3 +8,12 @@ register = template.Library() @register.filter(name='paper_nr_string_filter') def paper_nr_string_filter(nr): return paper_nr_string(nr) + +@register.filter(name='latest_successful_crossref_deposit') +def latest_crossref_deposition_date(publication): + latest = publication.deposit_set.filter( + deposit_successful=True).order_by('-deposition_date').first() + if latest: + return latest.deposition_date.strftime('%Y-%m-%d') + else: + return "No successful deposit found" diff --git a/journals/urls/general.py b/journals/urls/general.py index 76d8ab0b758416a861fe8b654cdd747bb3c4b7be..3fd938879af8c5c5c48efd01b797d8f557d29595 100644 --- a/journals/urls/general.py +++ b/journals/urls/general.py @@ -37,6 +37,9 @@ urlpatterns = [ url(r'^add_new_unreg_author/(?P<publication_id>[0-9]+)$', journals_views.add_new_unreg_author, name='add_new_unreg_author'), + url(r'^manage_metadata/$', + journals_views.manage_metadata, + name='manage_metadata'), url(r'^create_citation_list_metadata/(?P<doi_label>[a-zA-Z]+.[0-9]+.[0-9]+.[0-9]{3,})$', journals_views.create_citation_list_metadata, name='create_citation_list_metadata'), @@ -49,6 +52,12 @@ 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'^mark_deposit_success/(?P<deposit_id>[0-9]+)/(?P<success>[0-1])$', + journals_views.mark_deposit_success, + name='mark_deposit_success'), + url(r'^harvest_citedby_list/$', + journals_views.harvest_citedby_list, + name='harvest_citedby_list'), 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..4eb5a68106b50e0a52caa29f5114ba02f4ffdc2a 100644 --- a/journals/views.py +++ b/journals/views.py @@ -6,6 +6,7 @@ import string import xml.etree.ElementTree as ET from django.core.urlresolvers import reverse +from django.core.files.base import ContentFile from django.conf import settings from django.contrib import messages from django.utils import timezone @@ -20,6 +21,7 @@ from .forms import FundingInfoForm, InitiatePublicationForm, ValidatePublication UnregisteredAuthorForm, CreateMetadataXMLForm, CitationListBibitemsForm from .utils import JournalUtils +from journals.models import Publication, Deposit from submissions.models import Submission from scipost.models import Contributor @@ -269,6 +271,15 @@ def validate_publication(request): return render(request, 'journals/validate_publication.html', context) +@permission_required('scipost.can_publish_accepted_submission', return_403=True) +def manage_metadata(request): + publications = Publication.objects.order_by('-publication_date') + context = { + 'publications': publications + } + return render(request, 'journals/manage_metadata.html', context) + + @permission_required('scipost.can_publish_accepted_submission', return_403=True) @transaction.atomic def mark_first_author(request, publication_id, contributor_id): @@ -555,6 +566,7 @@ def create_metadata_xml(request, doi_label): '</journal>\n' ) initial['metadata_xml'] += '</body>\n</doi_batch>' + publication.latest_metadata_update = timezone.now() publication.save() context = {'publication': publication, @@ -579,7 +591,10 @@ def metadata_xml_deposit(request, doi_label, option='test'): else: errormessage = 'metadata_xml_deposit can only be called with options test or deposit' return render(request, 'scipost/error.html', context={'errormessage': errormessage}) - + if publication.metadata_xml is None: + errormessage = 'This publication has no metadata. Produce it first before saving it.' + return render(request, 'scipost/error.html', context={'errormessage': errormessage}) + # First perform the actual deposit to Crossref params = { 'operation': 'doMDUpload', 'login_id': settings.CROSSREF_LOGIN_ID, @@ -592,6 +607,24 @@ def metadata_xml_deposit(request, doi_label, option='test'): ) response_headers = r.headers response_text = r.text + + # Then, if deposit, create the associated Deposit object (saving the metadata to a file) + content = ContentFile(publication.metadata_xml) + timestamp = (publication.metadata_xml.partition( + '<timestamp>'))[2].partition('</timestamp>')[0] + doi_batch_id = (publication.metadata_xml.partition( + '<doi_batch_id>'))[2].partition('</doi_batch_id>')[0] + path = (settings.MEDIA_ROOT + publication.in_issue.path + '/' + + publication.get_paper_nr() + '/' + publication.doi_label.replace('.', '_') + + '_' + timestamp + '.xml') + deposit = Deposit(publication=publication, timestamp=timestamp, doi_batch_id=doi_batch_id, + metadata_xml=publication.metadata_xml, deposition_date=timezone.now()) + deposit.metadata_xml_file.save(path, content) + deposit.response_text = r.text + deposit.save() + publication.latest_crossref_deposit = timezone.now() + publication.save() + context = { 'option': option, 'publication': publication, @@ -601,6 +634,26 @@ 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 mark_deposit_success(request, deposit_id, success): + deposit = get_object_or_404(Deposit, pk=deposit_id) + if success == '1': + deposit.deposit_successful = True + elif success == '0': + deposit.deposit_successful = False + deposit.save() + return redirect(reverse('journals:manage_metadata')) + + +@permission_required('scipost.can_publish_accepted_submission', return_403=True) +def harvest_citedby_list(request): + publications = Publication.objects.order_by('-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 +690,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 +733,7 @@ def harvest_citedby_links(request, doi_label): 'item_number': item_number, 'year': year, }) publication.citedby = citations + publication.latest_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..0e9f37b82cf2420c147d8329978e11a0877838e9 100644 --- a/scipost/templates/scipost/personal_page.html +++ b/scipost/templates/scipost/personal_page.html @@ -263,6 +263,16 @@ {% 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:manage_metadata' %}">Manage metadata</a></li> + <li><a href="{% url 'journals:harvest_citedby_list' %}">Harvest citedby data</a></li> + {% endif %} + </ul> + {% endif %} + {% if perms.scipost.can_attend_VGMs %} <h3>Virtual General Meetings</h3> <ul>