diff --git a/SciPost_v1/urls.py b/SciPost_v1/urls.py index 5ed76657d6e6eeec5fe8c81e22293d0f595df43d..45b0ccceb5719cc0c844ada1eab1d077a36c427f 100644 --- a/SciPost_v1/urls.py +++ b/SciPost_v1/urls.py @@ -21,7 +21,7 @@ from ajax_select import urls as ajax_select_urls from journals.constants import REGEX_CHOICES -JOURNAL_REGEX = '(?P<doi_string>%s)' % REGEX_CHOICES +JOURNAL_REGEX = '(?P<doi_label>%s)' % REGEX_CHOICES urlpatterns = [ url(r'^admin/doc/', include('django.contrib.admindocs.urls')), diff --git a/journals/migrations/0016_auto_20170418_2120.py b/journals/migrations/0016_auto_20170418_2120.py new file mode 100644 index 0000000000000000000000000000000000000000..fdca76caa0da77deb695d2185d3db24dbb5d33db --- /dev/null +++ b/journals/migrations/0016_auto_20170418_2120.py @@ -0,0 +1,35 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.3 on 2017-04-18 19:20 +from __future__ import unicode_literals + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('journals', '0015_auto_20170408_1758'), + ] + + operations = [ + migrations.RenameField( + model_name='issue', + old_name='doi_string', + new_name='doi_label', + ), + migrations.RenameField( + model_name='journal', + old_name='doi_string', + new_name='doi_label', + ), + migrations.RenameField( + model_name='publication', + old_name='doi_string', + new_name='doi_label', + ), + migrations.RenameField( + model_name='volume', + old_name='doi_string', + new_name='doi_label', + ), + ] diff --git a/journals/models.py b/journals/models.py index b3f9f914c58eae30bd59e4fd517442e4f189800d..a50ff645958b35c03815f9baf13f1276a3e01ff9 100644 --- a/journals/models.py +++ b/journals/models.py @@ -26,16 +26,20 @@ class UnregisteredAuthor(models.Model): class Journal(models.Model): name = models.CharField(max_length=100, choices=SCIPOST_JOURNALS, unique=True) - doi_string = models.CharField(max_length=200, unique=True, db_index=True, - validators=[doi_journal_validator]) + doi_label = models.CharField(max_length=200, unique=True, db_index=True, + validators=[doi_journal_validator]) issn = models.CharField(max_length=16, default='2542-4653') active = models.BooleanField(default=True) def __str__(self): return self.get_name_display() + @property + def doi_string(self): + return '10.21468/' + self.doi_label + def get_absolute_url(self): - return reverse('scipost:landing_page', args=[self.doi_string]) + return reverse('scipost:landing_page', args=[self.doi_label]) def get_abbreviation_citation(self): return journal_name_abbrev_citation(self.name) @@ -46,8 +50,8 @@ class Volume(models.Model): number = models.PositiveSmallIntegerField() start_date = models.DateField(default=timezone.now) until_date = models.DateField(default=timezone.now) - doi_string = models.CharField(max_length=200, unique=True, db_index=True, - validators=[doi_volume_validator]) + doi_label = models.CharField(max_length=200, unique=True, db_index=True, + validators=[doi_volume_validator]) class Meta: unique_together = ('number', 'in_journal') @@ -55,6 +59,10 @@ class Volume(models.Model): def __str__(self): return str(self.in_journal) + ' Vol. ' + str(self.number) + @property + def doi_string(self): + return '10.21468/' + self.doi_label + class Issue(models.Model): in_volume = models.ForeignKey(Volume, on_delete=models.CASCADE) @@ -62,8 +70,8 @@ class Issue(models.Model): start_date = models.DateField(default=timezone.now) until_date = models.DateField(default=timezone.now) status = models.CharField(max_length=20, choices=ISSUE_STATUSES, default=STATUS_PUBLISHED) - doi_string = models.CharField(max_length=200, unique=True, db_index=True, - validators=[doi_issue_validator]) + doi_label = models.CharField(max_length=200, unique=True, db_index=True, + validators=[doi_issue_validator]) # absolute path on filesystem: (JOURNALS_DIR)/journal/vol/issue/ path = models.CharField(max_length=200) @@ -80,7 +88,11 @@ class Issue(models.Model): return text def get_absolute_url(self): - return reverse('scipost:issue_detail', args=[self.doi_string]) + return reverse('scipost:issue_detail', args=[self.doi_label]) + + @property + def doi_string(self): + return '10.21468/' + self.doi_label def short_str(self): return 'Vol. %s issue %s' % (self.in_volume.number, self.number) @@ -127,8 +139,8 @@ class Publication(models.Model): metadata = JSONField(default={}, blank=True, null=True) metadata_xml = models.TextField(blank=True, null=True) # for Crossref deposit BiBTeX_entry = models.TextField(blank=True, null=True) - doi_string = models.CharField(max_length=200, unique=True, db_index=True, - validators=[doi_publication_validator]) + 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') @@ -144,11 +156,11 @@ class Publication(models.Model): return header def get_absolute_url(self): - return reverse('scipost:publication_detail', args=[self.doi_string]) + return reverse('scipost:publication_detail', args=[self.doi_label]) @property - def complete_doi_string(self): - return '10.21468/' + self.doi_string + def doi_string(self): + return '10.21468/' + self.doi_label def get_paper_nr(self): return paper_nr_string(self.paper_nr) @@ -209,4 +221,4 @@ class Deposit(models.Model): def __str__(self): return (self.deposition_date.strftime('%Y-%m-%D') + - ' for 10.21468/' + self.publication.doi_string) + ' for 10.21468/' + self.publication.doi_label) diff --git a/journals/templates/journals/SciPostPhysProc_about.html b/journals/templates/journals/SciPostPhysProc_about.html index ea76b42877b54c128b18a9d1d453bbae0213b0ad..f7a9c191e4913fb37d219ed64b79cd52e966df9c 100644 --- a/journals/templates/journals/SciPostPhysProc_about.html +++ b/journals/templates/journals/SciPostPhysProc_about.html @@ -7,7 +7,7 @@ {% block breadcrumb_items %} {{block.super}} - <a href="{% url 'journal:issues' journal.doi_string %}" class="breadcrumb-item">SciPost Physics Proceedings</a> + <a href="{% url 'journal:issues' journal.doi_label %}" class="breadcrumb-item">SciPost Physics Proceedings</a> <span class="breadcrumb-item active">About</span> {% endblock %} diff --git a/journals/templates/journals/SciPostPhysProc_info_for_authors.html b/journals/templates/journals/SciPostPhysProc_info_for_authors.html index 84dc61b298716804bc32c415ac7e678a0e0248f4..618bc84191fc9f6aa05416798823de62001b66c5 100644 --- a/journals/templates/journals/SciPostPhysProc_info_for_authors.html +++ b/journals/templates/journals/SciPostPhysProc_info_for_authors.html @@ -6,7 +6,7 @@ {% block breadcrumb_items %} {{block.super}} - <a href="{% url 'journal:issues' journal.doi_string %}" class="breadcrumb-item">SciPost Physics Proceedings</a> + <a href="{% url 'journal:issues' journal.doi_label %}" class="breadcrumb-item">SciPost Physics Proceedings</a> <span class="breadcrumb-item active">Info for Authors</span> {% endblock %} diff --git a/journals/templates/journals/SciPostPhys_about.html b/journals/templates/journals/SciPostPhys_about.html index d49a4ed104c740f67112218bbe95a3891ca23f3c..94775192415a3f30c04fd6ecfd2258b9c2d74a70 100644 --- a/journals/templates/journals/SciPostPhys_about.html +++ b/journals/templates/journals/SciPostPhys_about.html @@ -7,7 +7,7 @@ {% block breadcrumb_items %} {{block.super}} - <a href="{% url 'journal:issues' journal.doi_string %}" class="breadcrumb-item">SciPost Physics</a> + <a href="{% url 'journal:issues' journal.doi_label %}" class="breadcrumb-item">SciPost Physics</a> <span class="breadcrumb-item active">About</span> {% endblock %} diff --git a/journals/templates/journals/SciPostPhys_info_for_authors.html b/journals/templates/journals/SciPostPhys_info_for_authors.html index 1463479ac41386f0e6f8cef9ff32aafac73868d7..73290333ee18b5d58e91f92e0196d21fad27d7a1 100644 --- a/journals/templates/journals/SciPostPhys_info_for_authors.html +++ b/journals/templates/journals/SciPostPhys_info_for_authors.html @@ -7,7 +7,7 @@ {% block breadcrumb_items %} {{block.super}} - <a href="{% url 'journal:issues' journal.doi_string %}" class="breadcrumb-item">SciPost Physics</a> + <a href="{% url 'journal:issues' journal.doi_label %}" class="breadcrumb-item">SciPost Physics</a> <span class="breadcrumb-item active">Info for Authors</span> {% endblock %} diff --git a/journals/templates/journals/_base.html b/journals/templates/journals/_base.html index ff06f0585508dcc67d6c110c9a48792207179804..f6d61a1c6c0ff323a8fc1f45b055407874b2502d 100644 --- a/journals/templates/journals/_base.html +++ b/journals/templates/journals/_base.html @@ -17,16 +17,16 @@ <div class="container my-2"> <nav class="navbar navbar-secondary px-0"> <div> - <h2 class="banner d-inline-block mr-2"><a href="{% url 'scipost:landing_page' journal.doi_string %}">{{journal}}</a></h2> + <h2 class="banner d-inline-block mr-2"><a href="{% url 'scipost:landing_page' journal.doi_label %}">{{journal}}</a></h2> <ul class="links"> {% if journal.active or request.user.is_staff %} - <li><a class="{% block link_class_physics_issues %}{% endblock %}" href="{% url 'journal:issues' journal.doi_string %}">Issues</a></li> - <li><a class="{% block link_class_physics_recent %}{% endblock %}" href="{% url 'journal:recent' journal.doi_string %}">Recent</a></li> - <li><a class="{% block link_class_physics_accepted %}{% endblock %}" href="{% url 'journal:accepted' journal.doi_string %}">Accepted</a></li> + <li><a class="{% block link_class_physics_issues %}{% endblock %}" href="{% url 'journal:issues' journal.doi_label %}">Issues</a></li> + <li><a class="{% block link_class_physics_recent %}{% endblock %}" href="{% url 'journal:recent' journal.doi_label %}">Recent</a></li> + <li><a class="{% block link_class_physics_accepted %}{% endblock %}" href="{% url 'journal:accepted' journal.doi_label %}">Accepted</a></li> <li><a href="{% url 'submissions:submissions' %}?to_journal=SciPostPhysics">Submissions</a></li> - <li><a class="{% block link_class_physics_info %}{% endblock %}" href="{% url 'journal:info_for_authors' journal.doi_string %}">Info for authors</a></li> + <li><a class="{% block link_class_physics_info %}{% endblock %}" href="{% url 'journal:info_for_authors' journal.doi_label %}">Info for authors</a></li> {% endif %} - <li><a class="{% block link_class_physics_about %}{% endblock %}" href="{% url 'journal:about' journal.doi_string %}">About</a></li> + <li><a class="{% block link_class_physics_about %}{% endblock %}" href="{% url 'journal:about' journal.doi_label %}">About</a></li> </ul> </div> </nav> diff --git a/journals/templates/journals/_publication_details.html b/journals/templates/journals/_publication_details.html index 091aba0175643f555ac37355d0862fd887aafffc..00c380eae42234ee2defbf909ef869bd97123aa3 100644 --- a/journals/templates/journals/_publication_details.html +++ b/journals/templates/journals/_publication_details.html @@ -8,7 +8,7 @@ <p class="text-muted">{{ publication.citation }} | published {{ publication.publication_date|date:'j F Y' }}</p> <ul class="publicationClickables"> - <li>doi: {{publication.complete_doi_string}}</li> + <li>doi: {{publication.doi_string}}</li> <li class="publicationPDF"> <a href="{{publication.get_absolute_url}}/pdf" target="_blank">pdf</a> </li> diff --git a/journals/templates/journals/create_citation_list_metadata.html b/journals/templates/journals/create_citation_list_metadata.html index 0ee96600058a0c0710ad4291091f691ad601a96d..037452a969156d6ed46ce3ec382531b43babf06a 100644 --- a/journals/templates/journals/create_citation_list_metadata.html +++ b/journals/templates/journals/create_citation_list_metadata.html @@ -14,7 +14,7 @@ <h2 style="color: red;">{{ errormessage }}</h2> {% endif %} - <form action="{% url 'journals:create_citation_list_metadata' doi_string=publication.doi_string %}" method="post"> + <form action="{% url 'journals:create_citation_list_metadata' publication.doi_label %}" method="post"> {% csrf_token %} {{ bibitems_form.as_p }} <input type="submit" value="Submit"> diff --git a/journals/templates/journals/create_funding_info_metadata.html b/journals/templates/journals/create_funding_info_metadata.html index 51b9ca431b987745fc1b07070c03f578e4e6c12c..5c953dd55e919990876bdbad2dfa86ed3ea86efd 100644 --- a/journals/templates/journals/create_funding_info_metadata.html +++ b/journals/templates/journals/create_funding_info_metadata.html @@ -14,7 +14,7 @@ <h2 style="color: red;">{{ errormessage }}</h2> {% endif %} - <form action="{% url 'journals:create_funding_info_metadata' doi_string=publication.doi_string %}" method="post"> + <form action="{% url 'journals:create_funding_info_metadata' publication.doi_label %}" method="post"> {% csrf_token %} {{ funding_info_form.as_p }} <input type="submit" value="Submit"> diff --git a/journals/templates/journals/create_metadata_xml.html b/journals/templates/journals/create_metadata_xml.html index 0e38965037acf6cef70e53c7956fc6dbdd75ec56..3caea010544c52b21d392abdfd87f0f02badd9c1 100644 --- a/journals/templates/journals/create_metadata_xml.html +++ b/journals/templates/journals/create_metadata_xml.html @@ -14,7 +14,7 @@ <h2 style="color: red;">{{ errormessage }}</h2> {% endif %} - <form action="{% url 'journals:create_metadata_xml' doi_string=publication.doi_string %}" method="post"> + <form action="{% url 'journals:create_metadata_xml' publication.doi_label %}" method="post"> {% csrf_token %} {{ create_metadata_xml_form.as_p }} <input type="submit" value="Accept the metadata"> diff --git a/journals/templates/journals/publication_detail.html b/journals/templates/journals/publication_detail.html index 854957a194adc5f966e594a4d04f9c9001515cf2..627d44a0a3c2c8fedd25916c52b7668dc18120b1 100644 --- a/journals/templates/journals/publication_detail.html +++ b/journals/templates/journals/publication_detail.html @@ -112,12 +112,12 @@ </div> </li> <li><a href="{% url 'journals:add_author' publication_id=publication.id %}">Add a missing author</a></li> - <li><a href="{% url 'journals:create_citation_list_metadata' doi_string=publication.doi_string %}">Create/update citation list metadata</a></li> - <li><a href="{% url 'journals:create_funding_info_metadata' doi_string=publication.doi_string %}">Create/update funding info metadata</a></li> - <li><a href="{% url 'journals:create_metadata_xml' doi_string=publication.doi_string %}">Create/update the XML metadata</a></li> - <li><a href="{% url 'journals:metadata_xml_deposit' doi_string=publication.doi_string option='test' %}">Test metadata deposit (via Crossref test server)</a></li> - <li><a href="{% url 'journals:metadata_xml_deposit' doi_string=publication.doi_string option='deposit' %}">Deposit the metadata to Crossref</a></li> - <li><a href="{% url 'journals:harvest_citedby_links' doi_string=publication.doi_string %}">Update Crossref cited-by links</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 %}">Create/update the XML metadata</a></li> + <li><a href="{% url 'journals:metadata_xml_deposit' publication.doi_label option='test' %}">Test metadata deposit (via Crossref test server)</a></li> + <li><a href="{% url 'journals:metadata_xml_deposit' publication.doi_label option='deposit' %}">Deposit the metadata to Crossref</a></li> + <li><a href="{% url 'journals:harvest_citedby_links' publication.doi_label %}">Update Crossref cited-by links</a></li> </ul> </div> </div> diff --git a/journals/urls/general.py b/journals/urls/general.py index 65ec93055c1a17a79df250b73b5abe8aa03e8fef..ba5227eebec603f2907e5bda74351a6533b24a77 100644 --- a/journals/urls/general.py +++ b/journals/urls/general.py @@ -36,19 +36,19 @@ 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'^create_citation_list_metadata/(?P<doi_string>[a-zA-Z]+.[0-9]+.[0-9]+.[0-9]{3,})$', + 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'), - url(r'^create_funding_info_metadata/(?P<doi_string>[a-zA-Z]+.[0-9]+.[0-9]+.[0-9]{3,})$', + url(r'^create_funding_info_metadata/(?P<doi_label>[a-zA-Z]+.[0-9]+.[0-9]+.[0-9]{3,})$', journals_views.create_funding_info_metadata, name='create_funding_info_metadata'), - url(r'^create_metadata_xml/(?P<doi_string>[a-zA-Z]+.[0-9]+.[0-9]+.[0-9]{3,})$', + url(r'^create_metadata_xml/(?P<doi_label>[a-zA-Z]+.[0-9]+.[0-9]+.[0-9]{3,})$', journals_views.create_metadata_xml, name='create_metadata_xml'), - url(r'^metadata_xml_deposit/(?P<doi_string>[a-zA-Z]+.[0-9]+.[0-9]+.[0-9]{3,})/(?P<option>[a-z]+)$', + 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/(?P<doi_string>[a-zA-Z]+.[0-9]+.[0-9]+.[0-9]{3,})$', + 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/urls/journal.py b/journals/urls/journal.py index b50e08235b5ee5052843905743492225c9fa8dd4..c18136fa3d5a038dafe829b603e10ab8c461e2a5 100644 --- a/journals/urls/journal.py +++ b/journals/urls/journal.py @@ -4,7 +4,6 @@ from journals import views as journals_views urlpatterns = [ # Journal routes - # url(r'^$', journals_views.landing_page, name='landing_page'), url(r'^issues$', journals_views.issues, name='issues'), url(r'^recent$', journals_views.recent, name='recent'), url(r'^accepted$', journals_views.accepted, name='accepted'), diff --git a/journals/views.py b/journals/views.py index fe649dbec4efa4a0a55a75ff65eae69150d3525c..959c2d4328669476d8151484682db64cc2bdd2a2 100644 --- a/journals/views.py +++ b/journals/views.py @@ -30,8 +30,8 @@ from guardian.decorators import permission_required # Journals ############ -def landing_page(request, doi_string): - journal = get_object_or_404(Journal, doi_string=doi_string) +def landing_page(request, doi_label): + journal = get_object_or_404(Journal, doi_label=doi_label) current_issue = Issue.objects.published( in_volume__in_journal=journal, @@ -56,8 +56,8 @@ def landing_page(request, doi_string): return render(request, 'journals/journal_landing_page.html', context) -def issues(request, doi_string): - journal = get_object_or_404(Journal, doi_string=doi_string) +def issues(request, doi_label): + journal = get_object_or_404(Journal, doi_label=doi_label) issues = Issue.objects.published(in_volume__in_journal=journal).order_by('-until_date') context = { @@ -67,11 +67,11 @@ def issues(request, doi_string): return render(request, 'journals/journal_issues.html', context) -def recent(request, doi_string): +def recent(request, doi_label): """ Display page for the most recent 20 publications in SciPost Physics. """ - journal = get_object_or_404(Journal, doi_string=doi_string) + journal = get_object_or_404(Journal, doi_label=doi_label) recent_papers = Publication.objects.published( in_issue__in_volume__in_journal=journal).order_by('-publication_date')[:20] context = { @@ -81,12 +81,12 @@ def recent(request, doi_string): return render(request, 'journals/journal_recent.html', context) -def accepted(request, doi_string): +def accepted(request, doi_label): """ Display page for submissions to SciPost Physics which have been accepted but are not yet published. """ - journal = get_object_or_404(Journal, doi_string=doi_string) + journal = get_object_or_404(Journal, doi_label=doi_label) accepted_SP_submissions = Submission.objects.filter( submitted_to_journal=journal.name, status='accepted' ).order_by('-latest_activity') @@ -97,24 +97,24 @@ def accepted(request, doi_string): return render(request, 'journals/journal_accepted.html', context) -def info_for_authors(request, doi_string): - journal = get_object_or_404(Journal, doi_string=doi_string) +def info_for_authors(request, doi_label): + journal = get_object_or_404(Journal, doi_label=doi_label) context = { 'journal': journal } - return render(request, 'journals/%s_info_for_authors.html' % doi_string, context) + return render(request, 'journals/%s_info_for_authors.html' % doi_label, context) -def about(request, doi_string): - journal = get_object_or_404(Journal, doi_string=doi_string) +def about(request, doi_label): + journal = get_object_or_404(Journal, doi_label=doi_label) context = { 'journal': journal } - return render(request, 'journals/%s_about.html' % doi_string, context) + return render(request, 'journals/%s_about.html' % doi_label, context) -def issue_detail(request, doi_string): - issue = Issue.objects.get_published(doi_string=doi_string) +def issue_detail(request, doi_label): + issue = Issue.objects.get_published(doi_label=doi_label) journal = issue.in_volume.in_journal papers = issue.publication_set.order_by('paper_nr') @@ -207,7 +207,6 @@ def initiate_publication(request): 'abstract': submission.abstract, 'BiBTeX_entry': BiBTeX_entry, 'doi_label': doi_label, - 'doi_string': doi_string, 'submission_date': initiate_publication_form.cleaned_data['original_submission_date'], 'acceptance_date': initiate_publication_form.cleaned_data['acceptance_date'], 'publication_date': timezone.now(), @@ -238,45 +237,42 @@ def validate_publication(request): # TODO: create metadata # TODO: set DOI, register with Crossref # TODO: add funding info - if request.method == 'POST': - validate_publication_form = ValidatePublicationForm(request.POST, request.FILES) - if validate_publication_form.is_valid(): - publication = validate_publication_form.save() - # Fill in remaining data - publication.pdf_file = request.FILES['pdf_file'] - submission = publication.accepted_submission - publication.authors.add(*submission.authors.all()) - publication.authors_claims.add(*submission.authors_claims.all()) - publication.authors_false_claims.add(*submission.authors_false_claims.all()) - publication.save() - # Move file to final location - initial_path = publication.pdf_file.path - new_dir = (settings.MEDIA_ROOT + publication.in_issue.path + '/' - + publication.get_paper_nr()) - new_path = new_dir + '/' + publication.doi_string.replace('.', '_') + '.pdf' - os.makedirs(new_dir) - os.rename(initial_path, new_path) - publication.pdf_file.name = new_path - publication.save() - # Mark the submission as having been published: - publication.accepted_submission.published_as = publication - publication.accepted_submission.status = 'published' - publication.accepted_submission.save() - # TODO: Create a Commentary Page - # Email authors - JournalUtils.load({'publication': publication}) - JournalUtils.send_authors_paper_published_email() - ack_header = 'The publication has been validated.' - context = {'ack_header': ack_header, } - return render(request, 'scipost/acknowledgement.html', context) - else: - errormessage = 'The form was invalid.' - context = {'validate_publication_form': validate_publication_form, - 'errormessage': errormessage} - return render(request, 'journals/validate_publication.html', context) + context = {} + validate_publication_form = ValidatePublicationForm(request.POST or None, + request.FILES or None) + if validate_publication_form.is_valid(): + publication = validate_publication_form.save() + # Fill in remaining data + publication.pdf_file = request.FILES['pdf_file'] + submission = publication.accepted_submission + publication.authors.add(*submission.authors.all()) + publication.authors_claims.add(*submission.authors_claims.all()) + publication.authors_false_claims.add(*submission.authors_false_claims.all()) + publication.save() + # Move file to final location + initial_path = publication.pdf_file.path + new_dir = (settings.MEDIA_ROOT + publication.in_issue.path + '/' + + publication.get_paper_nr()) + new_path = new_dir + '/' + publication.doi_label.replace('.', '_') + '.pdf' + os.makedirs(new_dir) + os.rename(initial_path, new_path) + publication.pdf_file.name = new_path + publication.save() + # Mark the submission as having been published: + publication.accepted_submission.published_as = publication + publication.accepted_submission.status = 'published' + publication.accepted_submission.save() + # TODO: Create a Commentary Page + # Email authors + JournalUtils.load({'publication': publication}) + JournalUtils.send_authors_paper_published_email() + ack_header = 'The publication has been validated.' + context['ack_header'] = ack_header + return render(request, 'scipost/acknowledgement.html', context) else: - validate_publication_form = ValidatePublicationForm() - context = {'validate_publication_form': validate_publication_form} + context['errormessage'] = 'The form was invalid.' + + context['validate_publication_form'] = validate_publication_form return render(request, 'journals/validate_publication.html', context) @@ -373,13 +369,13 @@ def add_new_unreg_author(request, publication_id): @permission_required('scipost.can_publish_accepted_submission', return_403=True) @transaction.atomic -def create_citation_list_metadata(request, doi_string): +def create_citation_list_metadata(request, doi_label): """ Called by an Editorial Administrator. This populates the citation_list dictionary entry in the metadata field in a Publication instance. """ - publication = get_object_or_404(Publication, doi_string=doi_string) + publication = get_object_or_404(Publication, doi_label=doi_label) if request.method == 'POST': bibitems_form = CitationListBibitemsForm(request.POST, request.FILES) if bibitems_form.is_valid(): @@ -405,13 +401,13 @@ def create_citation_list_metadata(request, doi_string): @permission_required('scipost.can_publish_accepted_submission', return_403=True) @transaction.atomic -def create_funding_info_metadata(request, doi_string): +def create_funding_info_metadata(request, doi_label): """ Called by an Editorial Administrator. This populates the funding_info dictionary entry in the metadata field in a Publication instance. """ - publication = get_object_or_404(Publication, doi_string=doi_string) + publication = get_object_or_404(Publication, doi_label=doi_label) if request.method == 'POST': funding_info_form = FundingInfoForm(request.POST) if funding_info_form.is_valid(): @@ -435,14 +431,14 @@ def create_funding_info_metadata(request, doi_string): @permission_required('scipost.can_publish_accepted_submission', return_403=True) @transaction.atomic -def create_metadata_xml(request, doi_string): +def create_metadata_xml(request, doi_label): """ To be called by an EdAdmin after the citation_list, funding_info entries have been filled. Populates the metadata_xml field of a Publication instance. The contents can then be sent to Crossref for registration. """ - publication = get_object_or_404(Publication, doi_string=doi_string) + publication = get_object_or_404(Publication, doi_label=doi_label) if request.method == 'POST': create_metadata_xml_form = CreateMetadataXMLForm(request.POST) @@ -485,9 +481,9 @@ def create_metadata_xml(request, doi_string): '</abbrev_title>\n' '<issn>' + publication.in_issue.in_volume.in_journal.issn + '</issn>\n' '<doi_data>\n' - '<doi>' + publication.in_issue.in_volume.in_journal.complete_doi_string + '</doi>\n' + '<doi>' + publication.in_issue.in_volume.in_journal.doi_string + '</doi>\n' '<resource>https://scipost.org/' - + publication.in_issue.in_volume.in_journal.complete_doi_string + '</resource>\n' + + publication.in_issue.in_volume.in_journal.doi_string + '</resource>\n' '</doi_data>\n' '</journal_metadata>\n' '<journal_issue>\n' @@ -548,12 +544,12 @@ def create_metadata_xml(request, doi_string): + paper_nr_string(publication.paper_nr) + '</item_number></publisher_item>\n' '<doi_data>\n' - '<doi>' + publication.complete_doi_string + '</doi>\n' - '<resource>https://scipost.org/' + publication.complete_doi_string + '</resource>\n' + '<doi>' + publication.doi_string + '</doi>\n' + '<resource>https://scipost.org/' + publication.doi_string + '</resource>\n' '<collection property="crawler-based">\n' '<item crawler="iParadigms">\n' '<resource>https://scipost.org/' - + publication.complete_doi_string + '/pdf</resource>\n' + + publication.doi_string + '/pdf</resource>\n' '</item></collection>\n' '</doi_data>\n' ) @@ -584,13 +580,13 @@ def create_metadata_xml(request, doi_string): @permission_required('scipost.can_publish_accepted_submission', return_403=True) @transaction.atomic -def metadata_xml_deposit(request, doi_string, option='test'): +def metadata_xml_deposit(request, doi_label, option='test'): """ Crossref metadata deposit. If test==True, test the metadata_xml using the Crossref test server. Makes use of the python requests module. """ - publication = get_object_or_404(Publication, doi_string=doi_string) + publication = get_object_or_404(Publication, doi_label=doi_label) if option == 'deposit': url = 'http://doi.crossref.org/servlet/deposit' elif option == 'test': @@ -622,8 +618,8 @@ def metadata_xml_deposit(request, doi_string, option='test'): @permission_required('scipost.can_publish_accepted_submission', return_403=True) @transaction.atomic -def harvest_citedby_links(request, doi_string): - publication = get_object_or_404(Publication, doi_string=doi_string) +def harvest_citedby_links(request, doi_label): + publication = get_object_or_404(Publication, doi_label=doi_label) # create a doi_batch_id salt = "" for i in range(5): @@ -643,7 +639,7 @@ def harvest_citedby_links(request, doi_string): '</head>' '<body>' '<fl_query alert="false">' - '<doi>' + publication.complete_doi_string + '</doi>' + '<doi>' + publication.doi_string + '</doi>' '</fl_query>' '</body>' '</query_batch>') @@ -651,7 +647,7 @@ def harvest_citedby_links(request, doi_string): params = {'usr': settings.CROSSREF_LOGIN_ID, 'pwd': settings.CROSSREF_LOGIN_PASSWORD, 'qdata': query_xml, - 'doi': publication.complete_doi_string, } + 'doi': publication.doi_string, } r = requests.post(url, params=params,) response_headers = r.headers response_text = r.text @@ -710,8 +706,8 @@ def harvest_citedby_links(request, doi_string): # Viewing # ########### -def publication_detail(request, doi_string): - publication = Publication.objects.get_published(doi_string=doi_string) +def publication_detail(request, doi_label): + publication = Publication.objects.get_published(doi_label=doi_label) journal = publication.in_issue.in_volume.in_journal context = { @@ -721,9 +717,9 @@ def publication_detail(request, doi_string): return render(request, 'journals/publication_detail.html', context) -def publication_detail_pdf(request, doi_string): - publication = Publication.objects.get_published(doi_string=doi_string) +def publication_detail_pdf(request, doi_label): + publication = Publication.objects.get_published(doi_label=doi_label) response = HttpResponse(publication.pdf_file.read(), content_type='application/pdf') response['Content-Disposition'] = ('filename=' - + publication.doi_string.replace('.', '_') + '.pdf') + + publication.doi_label.replace('.', '_') + '.pdf') return response diff --git a/scipost/urls.py b/scipost/urls.py index 7e2664d51028fab3c4f19b581bbca44ee2a74d57..ebbd67e5fb89ad0a5811e49ea46fdd445b7351fe 100644 --- a/scipost/urls.py +++ b/scipost/urls.py @@ -9,7 +9,7 @@ from .feeds import LatestNewsFeedRSS, LatestNewsFeedAtom, LatestCommentsFeedRSS, from journals import views as journals_views from journals.constants import REGEX_CHOICES -JOURNAL_REGEX = '(?P<doi_string>%s)' % REGEX_CHOICES +JOURNAL_REGEX = '(?P<doi_label>%s)' % REGEX_CHOICES urlpatterns = [ url(r'^$', views.index, name='index'), @@ -175,23 +175,23 @@ urlpatterns = [ ################ # Publication detail (+pdf) - url(r'^10.21468/(?P<doi_string>[a-zA-Z]+.[0-9]+.[0-9]+.[0-9]{3,})$', + url(r'^10.21468/(?P<doi_label>[a-zA-Z]+.[0-9]+.[0-9]+.[0-9]{3,})$', journals_views.publication_detail, name='publication_detail'), - url(r'^(?P<doi_string>[a-zA-Z]+.[0-9]+.[0-9]+.[0-9]{3,})$', + url(r'^(?P<doi_label>[a-zA-Z]+.[0-9]+.[0-9]+.[0-9]{3,})$', journals_views.publication_detail, name='publication_detail'), - url(r'^10.21468/(?P<doi_string>[a-zA-Z]+.[0-9]+.[0-9]+.[0-9]{3,})/pdf$', + url(r'^10.21468/(?P<doi_label>[a-zA-Z]+.[0-9]+.[0-9]+.[0-9]{3,})/pdf$', journals_views.publication_detail_pdf, name='publication_pdf'), - url(r'^(?P<doi_string>[a-zA-Z]+.[0-9]+.[0-9]+.[0-9]{3,})/pdf$', + url(r'^(?P<doi_label>[a-zA-Z]+.[0-9]+.[0-9]+.[0-9]{3,})/pdf$', journals_views.publication_detail_pdf, name='publication_pdf'), # Journal issue - url(r'^10.21468/(?P<doi_string>[a-zA-Z]+.[0-9]+.[0-9])$', + url(r'^10.21468/(?P<doi_label>[a-zA-Z]+.[0-9]+.[0-9])$', journals_views.issue_detail, name='issue_detail'), - url(r'^(?P<doi_string>[a-zA-Z]+.[0-9]+.[0-9])$', + url(r'^(?P<doi_label>[a-zA-Z]+.[0-9]+.[0-9])$', journals_views.issue_detail, name='issue_detail'), # Journal landing page diff --git a/scipost/utils.py b/scipost/utils.py index f0f3ebcd37e23b5217169ab87e0c1b386b227c41..07da56a2a7a0f5c5eb0f312a2a4156112bade871 100644 --- a/scipost/utils.py +++ b/scipost/utils.py @@ -392,7 +392,7 @@ class Utils(BaseMailUtil): 'Contributor to the site.</p>') email_context['pub_title'] = cls.invitation.cited_in_publication.title email_context['pub_author_list'] = cls.invitation.cited_in_publication.author_list - email_context['doi_label'] = cls.invitation.cited_in_publication.doi_string + email_context['doi_label'] = cls.invitation.cited_in_publication.doi_label email_context['citation'] = cls.invitation.cited_in_publication.citation() email_text += summary_text email_text_html += summary_text_html @@ -631,7 +631,7 @@ class Utils(BaseMailUtil): '<a href="%s">Unsubscribe</a>.</p>' % url_unsubscribe) email_context['pub_title'] = cls.notification.cited_in_publication.title email_context['pub_author_list'] = cls.notification.cited_in_publication.author_list - email_context['doi_label'] = cls.notification.cited_in_publication.doi_string + email_context['doi_label'] = cls.notification.cited_in_publication.doi_label email_context['citation'] = cls.notification.cited_in_publication.citation() email_context['key'] = cls.notification.contributor.activation_key html_template = Template(email_text_html) diff --git a/scipost/views.py b/scipost/views.py index ce6d28389dae03ed225d0ab5eee2ea6d64b4ef88..d3ad00c66f0084805cc474d2741a24ef3f580771 100644 --- a/scipost/views.py +++ b/scipost/views.py @@ -86,7 +86,7 @@ def documentsSearchResults(query): Naive implementation based on exact match of query. NEEDS UPDATING with e.g. Haystack. """ - publication_query = get_query(query, ['title', 'author_list', 'abstract', 'doi_string']) + publication_query = get_query(query, ['title', 'author_list', 'abstract', 'doi_label']) commentary_query = get_query(query, ['pub_title', 'author_list', 'pub_abstract']) submission_query = get_query(query, ['title', 'author_list', 'abstract']) thesislink_query = get_query(query, ['title', 'author', 'abstract', 'supervisor']) diff --git a/submissions/models.py b/submissions/models.py index 1e15662cff72c521acc024ccbf6c2f0e056a34a3..0a2b82f9ae8f5dfb2a42b6a9df8c0a3978d772e3 100644 --- a/submissions/models.py +++ b/submissions/models.py @@ -105,7 +105,7 @@ class Submission(ArxivCallable, models.Model): header += ' (deprecated version ' + str(self.arxiv_vn_nr) + ')' try: header += ' (published as %s (%s))' % (self.publication.doi_string, - self.publication.publication_date.strftime('%Y')) + self.publication.publication_date.strftime('%Y')) except Publication.DoesNotExist: pass return header