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/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 0e52387101850c0488f08b41166227ca1c98391f..3f5454a8f8edf552449f05324e644d8d6cac8718 100644 --- a/journals/models.py +++ b/journals/models.py @@ -225,7 +225,7 @@ class Deposit(models.Model): timestamp = models.CharField(max_length=40, default='') doi_batch_id = models.CharField(max_length=40, default='') metadata_xml = models.TextField(blank=True, null=True) - metadata_xml_file = models.FileField(blank=True, null=True) + 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) diff --git a/journals/templates/journals/manage_metadata.html b/journals/templates/journals/manage_metadata.html index 961591fa261419542a067ae050c167a009dc19a9..2d5ec8c2408bec25d1d633d422a2e865a7dc6f7a 100644 --- a/journals/templates/journals/manage_metadata.html +++ b/journals/templates/journals/manage_metadata.html @@ -54,6 +54,7 @@ event: "focusin" </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"> @@ -87,24 +88,35 @@ event: "focusin" <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> - <table> - {% 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>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 %} + <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> 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/urls/general.py b/journals/urls/general.py index dacdd5bb478e3eeaf0da74643bc8b6e716e9cafb..3fd938879af8c5c5c48efd01b797d8f557d29595 100644 --- a/journals/urls/general.py +++ b/journals/urls/general.py @@ -52,7 +52,7 @@ 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_as_successful/(?P<deposit_id>[0-9]+)/(?P<success>[0-1])$', + 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/$', diff --git a/journals/views.py b/journals/views.py index 00221b7fab2cb59fcb6634d1b1c71ad2604a5d4c..4eb5a68106b50e0a52caa29f5114ba02f4ffdc2a 100644 --- a/journals/views.py +++ b/journals/views.py @@ -21,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 @@ -608,22 +609,21 @@ def metadata_xml_deposit(request, doi_label, option='test'): response_text = r.text # Then, if deposit, create the associated Deposit object (saving the metadata to a file) - if option == 'deposit': - 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() + 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, @@ -635,7 +635,7 @@ def metadata_xml_deposit(request, doi_label, option='test'): @permission_required('scipost.can_publish_accepted_submission', return_403=True) -def mark_deposit_success(deposit_id, success): +def mark_deposit_success(request, deposit_id, success): deposit = get_object_or_404(Deposit, pk=deposit_id) if success == '1': deposit.deposit_successful = True