diff --git a/funders/forms.py b/funders/forms.py index 64676af4446f442411f856981a0393bf8a512945..b7db43fcb0ecb60b2ed0e9e8ebb0e3afacc2b6fb 100644 --- a/funders/forms.py +++ b/funders/forms.py @@ -2,6 +2,9 @@ from django import forms from .models import Funder, Grant +from scipost.models import Contributor + + class FunderRegistrySearchForm(forms.Form): name = forms.CharField(max_length=128) @@ -9,13 +12,23 @@ class FunderRegistrySearchForm(forms.Form): class FunderForm(forms.ModelForm): class Meta: model = Funder - fields = ['name', 'identifier',] + fields = ['name', 'acronym', 'identifier',] + + +class FunderSelectForm(forms.Form): + funder = forms.ModelChoiceField(queryset=Funder.objects.all()) class GrantForm(forms.ModelForm): class Meta: model = Grant - fields = ['funder', 'number', 'recipient_name', 'recipient',] + fields = ['funder', 'number', 'recipient_name', 'recipient', 'further_details'] + + def __init__(self, *args, **kwargs): + super(GrantForm, self).__init__(*args, **kwargs) + self.fields['recipient'] = forms.ModelChoiceField( + queryset=Contributor.objects.all().order_by('user__last_name'), + required=False) class GrantSelectForm(forms.Form): diff --git a/funders/migrations/0004_auto_20170726_2037.py b/funders/migrations/0004_auto_20170726_2037.py new file mode 100644 index 0000000000000000000000000000000000000000..59544eb74125ea1719eaa0443a713a567ee15159 --- /dev/null +++ b/funders/migrations/0004_auto_20170726_2037.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.3 on 2017-07-26 18:37 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('funders', '0003_auto_20170726_0606'), + ] + + operations = [ + migrations.AlterModelOptions( + name='funder', + options={'ordering': ['name', 'acronym']}, + ), + migrations.AddField( + model_name='funder', + name='acronym', + field=models.CharField(blank=True, max_length=32, null=True), + ), + ] diff --git a/funders/migrations/0005_grant_further_details.py b/funders/migrations/0005_grant_further_details.py new file mode 100644 index 0000000000000000000000000000000000000000..095cd8735b666a133bce4ffde5cad79ab8202cb7 --- /dev/null +++ b/funders/migrations/0005_grant_further_details.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.3 on 2017-07-27 04:12 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('funders', '0004_auto_20170726_2037'), + ] + + operations = [ + migrations.AddField( + model_name='grant', + name='further_details', + field=models.CharField(blank=True, max_length=256, null=True), + ), + ] diff --git a/funders/models.py b/funders/models.py index 3957bf92f13ae9a3825a06aa780e68c6063e6b73..b0cba639a76892890c968812958aae7be5e62bd7 100644 --- a/funders/models.py +++ b/funders/models.py @@ -7,13 +7,17 @@ class Funder(models.Model): Fundref registry. """ name = models.CharField(max_length=256) + acronym = models.CharField(max_length=32, blank=True, null=True) identifier = models.CharField(max_length=200, unique=True) class Meta: - ordering = ['name'] + ordering = ['name', 'acronym'] def __str__(self): - return self.name + result = self.name + if self.acronym: + result += ' (%s)' % self.acronym + return result class Grant(models.Model): @@ -27,6 +31,7 @@ class Grant(models.Model): recipient_name = models.CharField(max_length=64, blank=True, null=True) recipient = models.ForeignKey('scipost.Contributor', blank=True, null=True, on_delete=models.CASCADE) + further_details = models.CharField(max_length=256, blank=True, null=True) class Meta: ordering = ['funder', 'recipient', 'recipient_name', 'number'] @@ -38,4 +43,6 @@ class Grant(models.Model): grantstring += ' (%s)' % str(self.recipient) elif self.recipient_name: grantstring += ' (%s)' % self.recipient_name + if self.further_details: + grantstring += ' [%s]' % self.further_details return grantstring diff --git a/funders/templates/funders/funders.html b/funders/templates/funders/funders.html index 7ae67d06b8fa03d6fb504cd5475f30f1c22120cb..cd9dfd6d4c2f7afc44d157a94a4471d7113720b0 100644 --- a/funders/templates/funders/funders.html +++ b/funders/templates/funders/funders.html @@ -57,6 +57,7 @@ <thead class="thead-default"> <tr> <th>Name</th> + <th>Acronym</th> <th>Identifier</th> </tr> </thead> @@ -64,6 +65,7 @@ {% for funder in funders %} <tr data-toggle="collapse" data-parent="#accordion" href="#collapse{{ funder.id }}" aria-expanded="true" aria-controls="collapse{{ funder.id }}" style="cursor: pointer;"> <td>{{ funder.name }}</td> + <td>{{ funder.acronym }}</td> <td>{{ funder.identifier }}</td> </tr> {% empty %} diff --git a/funders/templates/funders/query_crossref_for_funder.html b/funders/templates/funders/query_crossref_for_funder.html index b8459c8a21ff63b830f9c8919fdefb2fe28f9174..35c1b9a7ee15dbe05d6c0dabdcad77b83ce9e30e 100644 --- a/funders/templates/funders/query_crossref_for_funder.html +++ b/funders/templates/funders/query_crossref_for_funder.html @@ -29,6 +29,7 @@ <form action="{% url 'funders:add_funder' %}" method="post"> {% csrf_token %} <input name='name' style="width: 64%" value='{{ item.name }}'> + <input name='acronym' style="width: 64%" placeholder='acronym (if known)'> <input name='identifier' style="width: 64%" value='{{ item.uri }}'> <input class="btn btn-secondary" type="submit" value="Add this funder"> </form> diff --git a/journals/constants.py b/journals/constants.py index 7db8b8c2a556c43aaddb121825a6ec209746412e..7673cf16062813b0d1ceba90839c40b082fce962 100644 --- a/journals/constants.py +++ b/journals/constants.py @@ -65,3 +65,9 @@ CC_LICENSES = ( (CCBYSA4, 'CC BY-SA (4.0)'), (CCBYNC4, 'CC BY-NC (4.0)'), ) + +CC_LICENSES_URI = ( + (CCBY4, 'https://creativecommons.org/licenses/by/4.0'), + (CCBYSA4, 'https://creativecommons.org/licenses/by-sa/4.0'), + (CCBYNC4, 'https://creativecommons.org/licenses/by-nc/4.0'), + ) diff --git a/journals/helpers.py b/journals/helpers.py index d1d656c2bad92ed789800d15dbe3685f93ca4d84..6c097de27734169f18446b14b253ec9923a1059b 100644 --- a/journals/helpers.py +++ b/journals/helpers.py @@ -1,6 +1,18 @@ +import re + from .exceptions import JournalNameError, PaperNumberError +def issue_doi_label_from_doi_label(doi_label): + """ + Strip the last digits block from the label. + """ + m = re.match(r'[a-zA-Z]+.[0-9]+.[0-9]+', doi_label) + s = m.start() + e = m.end() + return doi_label[s:e] + + def journal_name_abbrev_citation(journal_name): if journal_name == 'SciPostPhys': return 'SciPost Phys.' diff --git a/journals/migrations/0041_publication_funders_generic.py b/journals/migrations/0041_publication_funders_generic.py new file mode 100644 index 0000000000000000000000000000000000000000..419bf2f1282102d83e154ff15449fabc1f687001 --- /dev/null +++ b/journals/migrations/0041_publication_funders_generic.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.3 on 2017-07-27 04:12 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('funders', '0005_grant_further_details'), + ('journals', '0040_merge_20170726_0945'), + ] + + operations = [ + migrations.AddField( + model_name='publication', + name='funders_generic', + field=models.ManyToManyField(blank=True, to='funders.Funder'), + ), + ] diff --git a/journals/models.py b/journals/models.py index 0953c805a28042c65e1c62ea131ea8772344c48f..d539244250d48992603501f25ffc47f94ee73cdf 100644 --- a/journals/models.py +++ b/journals/models.py @@ -8,7 +8,7 @@ from .behaviors import doi_journal_validator, doi_volume_validator,\ doi_issue_validator, doi_publication_validator from .constants import SCIPOST_JOURNALS, SCIPOST_JOURNALS_DOMAINS,\ STATUS_DRAFT, STATUS_PUBLISHED, ISSUE_STATUSES,\ - CCBY4, CC_LICENSES + CCBY4, CC_LICENSES, CC_LICENSES_URI from .helpers import paper_nr_string, journal_name_abbrev_citation from .managers import IssueManager, PublicationManager @@ -143,6 +143,7 @@ class Publication(models.Model): pdf_file = models.FileField(upload_to='UPLOADS/PUBLICATIONS/%Y/%m/', max_length=200) cc_license = models.CharField(max_length=32, choices=CC_LICENSES, default=CCBY4) grants = models.ManyToManyField('funders.Grant', blank=True) + funders_generic = models.ManyToManyField('funders.Funder', blank=True) # not linked to a grant 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) @@ -168,6 +169,12 @@ class Publication(models.Model): def get_absolute_url(self): return reverse('scipost:publication_detail', args=[self.doi_label]) + def get_cc_license_URI(self): + for (key, val) in CC_LICENSES_URI: + if key == self.cc_license: + return val + raise KeyError + @property def doi_string(self): return '10.21468/' + self.doi_label diff --git a/journals/templates/journals/_publication_details.html b/journals/templates/journals/_publication_details.html index 2f9ddcf3e9db287d74494159f9349c8fc5cbf1d6..b91b561f69b9ceb9f5f964b548f4ea37537ff1ae 100644 --- a/journals/templates/journals/_publication_details.html +++ b/journals/templates/journals/_publication_details.html @@ -17,7 +17,7 @@ <li> <!-- Start Crossmark Snippet v2.0 --> <script src="https://crossmark-cdn.crossref.org/widget/v2.0/widget.js"></script> - <a data-target="crossmark"><img src="https://crossmark-cdn.crossref.org/widget/v2.0/logos/CROSSMARK_Color_horizontal.svg" width="120" /></a> + <a data-target="crossmark"><img src="https://crossmark-cdn.crossref.org/widget/v2.0/logos/CROSSMARK_BW_horizontal.svg" width="120" /></a> <!-- End Crossmark Snippet --> </li> </ul> diff --git a/journals/templates/journals/create_citation_list_metadata.html b/journals/templates/journals/create_citation_list_metadata.html index a7d68067d8aeede3f8971ebc9c706923f097c72e..c42b5f44725791918c62da5621955c2a570fef52 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> or to the <a href="{% url 'journals:manage_metadata' %}">metadata management 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> or to <a href="{% url 'journals:manage_metadata' doi_label=publication.doi_label %}">this publication's 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 7e918a563af0236bd0ce89cc15ae7fdd832c8d60..790a54f46e235a2ca6b25ed4a5dd8190e4bec563 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> or to the <a href="{% url 'journals:manage_metadata' %}">metadata management 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> or to <a href="{% url 'journals:manage_metadata' doi_label=publication.doi_label %}">this publication's 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 6fcb9803386abcfba0d9d5996538c6e700ab2db2..8e772ab695d824230202c7ae1172c32d7bb9465c 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> or to the <a href="{% url 'journals:manage_metadata' %}">metadata management 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' %}">general metadata management page</a> or to <a href="{% url 'journals:manage_metadata' doi_label=publication.doi_label %}">this publication's metadata management page</a></h3> </section> diff --git a/journals/templates/journals/harvest_citedby_links.html b/journals/templates/journals/harvest_citedby_links.html index f39d1d0b940b81eda93d59ad4a435220c1a5e2f4..5d10c46e5af66d536f061f553a2058d49d47f7f7 100644 --- a/journals/templates/journals/harvest_citedby_links.html +++ b/journals/templates/journals/harvest_citedby_links.html @@ -52,7 +52,7 @@ {% endfor %} {{ nr }} - <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> or to <a href="{% url 'journals:manage_metadata' doi_label=publication.doi_label %}">this publication's metadata management page</a></h3> </section> diff --git a/journals/templates/journals/manage_metadata.html b/journals/templates/journals/manage_metadata.html index 89f1796afce4c103f9dba4c3e3b991e10555f8b6..7025abe2757158aeed4e78e5dce2144ecc013401 100644 --- a/journals/templates/journals/manage_metadata.html +++ b/journals/templates/journals/manage_metadata.html @@ -23,7 +23,18 @@ event: "focusin" <div class="row"> <div class="col-12"> - <h1 class="highlight">Manage Publications Metadata</h1> + <h1 class="highlight">Manage Publications Metadata{% if issue_doi_label %} for issue {{ issue_doi_label }}{% endif %}</h1> + {% if issue_doi_label %} + <h3>Return to the <a href="{% url 'journals:manage_metadata' %}">Main manage metadata page</a></h3> + {% endif %} + <h3>Manage metadata per issue:</h3> + <ul> + {% for issue in issues %} + <li> + <a href="{% url 'journals:manage_metadata' issue_doi_label=issue.doi_label %}">{{ issue }}</a> + </li> + {% endfor %} + </ul> </div> </div> @@ -88,20 +99,21 @@ event: "focusin" <li><a href="{% url 'journals:metadata_xml_deposit' publication.doi_label 'deposit' %}">Deposit the metadata to Crossref</a></li> <li><a href="{% url 'journals:produce_metadata_DOAJ' doi_label=publication.doi_label %}">Produce DOAJ metadata</a></li> <li><a href="{% url 'journals:metadata_DOAJ_deposit' doi_label=publication.doi_label %}">Deposit the metadata to DOAJ</a></li> + <li><a href="{% url 'journals:harvest_citedby_links' publication.doi_label %}">Update Crossref cited-by links</a></li> </ul> </div> <div class="col-md-5"> - <h2>Funding info for this publication:</h2> - {% if publication.funding_info %} - <p>{{ publication.funding_info }}</p> + <h2>Funding statement for this publication:</h2> + {% if publication.metadata.funding_statement %} + <p>{{ publication.metadata.funding_statement }}</p> {% else %} - <p>No funding info was found</p> + <p>No funding statement was found</p> {% endif %} <h2>Grants associated to this publication:</h2> <ul> {% for grant in publication.grants.all %} - <li> {{ grant }}</li> + <li>{{ grant }}</li> {% empty %} <li>no associated grants found</li> {% endfor %} @@ -113,7 +125,23 @@ event: "focusin" {{associate_grant_form|bootstrap}} <input class="btn btn-secondary" type="submit" value="Add"> </form> - <h3>Other grant-related actions:</h3> + <br/> + <h2>Generic (not via grant) funders associated to this publication:</h2> + <ul> + {% for funder in publication.funders_generic.all %} + <li>{{ funder }}</li> + {% empty %} + <li>No generic funder found</li> + {% endfor %} + </ul> + <h3>Associate a generic funder to this publication:</h3> + <form action="{% url 'journals:add_generic_funder' publication.doi_label %}" method="post"> + {% csrf_token %} + {{associate_generic_funder_form|bootstrap}} + <input class="btn btn-secondary" type="submit" value="Add"> + </form> + <br/> + <h3>Other funding-related actions:</h3> <ul> <li><a href="{% url 'funders:funders' %}" target="_blank">go to the Funders page to add a Funder and/or Grant instance</a></li> </ul> diff --git a/journals/templates/journals/metadata_xml_deposit.html b/journals/templates/journals/metadata_xml_deposit.html index 645cba7c0b3d86dd2356e729ce5f22c62bcc7956..e8fbc3a40e48695ecd2cc9a47be694f8773709c4 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> or to the <a href="{% url 'journals:manage_metadata' %}">metadata management page</a></h3> + <h3><a href="{{publication.get_absolute_url}}">return to the publication's page</a>, to the <a href="{% url 'journals:manage_metadata' %}">general metadata management page</a> or to <a href="{% url 'journals:manage_metadata' doi_label=publication.doi_label %}">this publication's metadata management page</a></h3> </section> diff --git a/journals/templates/journals/publication_detail.html b/journals/templates/journals/publication_detail.html index 65a1ce40d09247a4cd9eb8d376e3d47a71586b45..fb2fa570aa16d3d442a9372580c39c22c652b3d9 100644 --- a/journals/templates/journals/publication_detail.html +++ b/journals/templates/journals/publication_detail.html @@ -87,40 +87,11 @@ <div class="row"> <div class="col-12"> <hr> - <h3>Editorial Administration tools: </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 %}">Create/update the XML 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> - <li><a href="{% url 'journals:harvest_citedby_links' publication.doi_label %}">Update Crossref cited-by links</a></li> - </ul> + <h3>Editorial Administration tools: </h3> + <ul> + <li><a href="{% url 'journals:manage_metadata' %}">metadata management page</a></li> + <li><a href="{% url 'journals:manage_metadata' doi_label=publication.doi_label %}">this publication's metadata management page</a></li> + </ul> </div> </div> {% endif %} diff --git a/journals/urls/general.py b/journals/urls/general.py index b1ba8d539c6094835068874e38bb11008623b14e..648fb35f2d89db923389106052575bee397b09a5 100644 --- a/journals/urls/general.py +++ b/journals/urls/general.py @@ -41,6 +41,12 @@ 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/(?P<doi_label>[a-zA-Z]+.[0-9]+.[0-9]+.[0-9]{3,})$', + journals_views.manage_metadata, + name='manage_metadata'), + url(r'^manage_metadata/(?P<issue_doi_label>[a-zA-Z]+.[0-9]+.[0-9]+)$', + journals_views.manage_metadata, + name='manage_metadata'), url(r'^manage_metadata/$', journals_views.manage_metadata, name='manage_metadata'), @@ -53,6 +59,9 @@ urlpatterns = [ url(r'^add_associated_grant/(?P<doi_label>[a-zA-Z]+.[0-9]+.[0-9]+.[0-9]{3,})$', journals_views.add_associated_grant, name='add_associated_grant'), + url(r'^add_generic_funder/(?P<doi_label>[a-zA-Z]+.[0-9]+.[0-9]+.[0-9]{3,})$', + journals_views.add_generic_funder, + name='add_generic_funder'), 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'), diff --git a/journals/views.py b/journals/views.py index 4f073a1a6d6f7550840ed21fe9d4014398ca920b..cfad3589f08b7122be94564f8018183be665b3ff 100644 --- a/journals/views.py +++ b/journals/views.py @@ -16,7 +16,7 @@ from django.db import transaction from django.http import HttpResponse from .exceptions import PaperNumberingError -from .helpers import paper_nr_string +from .helpers import paper_nr_string, issue_doi_label_from_doi_label from .models import Journal, Issue, Publication, UnregisteredAuthor, Deposit, DOAJDeposit from .forms import FundingInfoForm, InitiatePublicationForm, ValidatePublicationForm,\ UnregisteredAuthorForm, CreateMetadataXMLForm, CitationListBibitemsForm @@ -26,7 +26,7 @@ from funders.models import Funder from submissions.models import Submission from scipost.models import Contributor -from funders.forms import GrantSelectForm +from funders.forms import FunderSelectForm, GrantSelectForm from guardian.decorators import permission_required @@ -271,12 +271,22 @@ def validate_publication(request): @permission_required('scipost.can_publish_accepted_submission', return_403=True) -def manage_metadata(request): - publications = Publication.objects.order_by('-publication_date', '-paper_nr') +def manage_metadata(request, issue_doi_label=None, doi_label=None): + issues = Issue.objects.all().order_by('-until_date') + publications = Publication.objects.all() + if doi_label: + issue_doi_label = issue_doi_label_from_doi_label(doi_label) + if issue_doi_label: + publications = publications.filter(in_issue__doi_label=issue_doi_label) + publications = publications.order_by('-publication_date', '-paper_nr') associate_grant_form = GrantSelectForm() + associate_generic_funder_form = FunderSelectForm() context = { + 'issues': issues, + 'issue_doi_label': issue_doi_label, 'publications': publications, 'associate_grant_form': associate_grant_form, + 'associate_generic_funder_form': associate_generic_funder_form, } return render(request, 'journals/manage_metadata.html', context) @@ -289,7 +299,8 @@ def mark_first_author(request, publication_id, contributor_id): publication.first_author = contributor publication.first_author_unregistered = None publication.save() - return redirect(publication.get_absolute_url()) + return redirect(reverse('journals:manage_metadata', + kwargs={'doi_label': publication.doi_label})) @permission_required('scipost.can_publish_accepted_submission', return_403=True) @@ -300,7 +311,8 @@ def mark_first_author_unregistered(request, publication_id, unregistered_author_ publication.first_author = None publication.first_author_unregistered = unregistered_author publication.save() - return redirect(publication.get_absolute_url()) + return redirect(reverse('journals:manage_metadata', + kwargs={'doi_label': publication.doi_label})) @permission_required('scipost.can_publish_accepted_submission', return_403=True) @@ -317,7 +329,8 @@ def add_author(request, publication_id, contributor_id=None, unregistered_author contributor = get_object_or_404(Contributor, id=contributor_id) publication.authors.add(contributor) publication.save() - return redirect(publication.get_absolute_url()) + return redirect(reverse('journals:manage_metadata', + kwargs={'doi_label': publication.doi_label})) if request.method == 'POST': form = UnregisteredAuthorForm(request.POST) @@ -352,7 +365,8 @@ def add_unregistered_author(request, publication_id, unregistered_author_id): unregistered_author = get_object_or_404(UnregisteredAuthor, id=unregistered_author_id) publication.unregistered_authors.add(unregistered_author) publication.save() - return redirect(publication.get_absolute_url()) + return redirect(reverse('journals:manage_metadata', + kwargs={'doi_label': publication.doi_label})) @permission_required('scipost.can_publish_accepted_submission', return_403=True) @@ -364,7 +378,8 @@ def add_new_unreg_author(request, publication_id): if new_unreg_author_form.is_valid(): new_unreg_author = new_unreg_author_form.save() publication.authors_unregistered.add(new_unreg_author) - return redirect(publication.get_absolute_url()) + return redirect(reverse('journals:manage_metadata', + kwargs={'doi_label': publication.doi_label})) raise Http404 @@ -435,7 +450,25 @@ def add_associated_grant(request, doi_label): publication.grants.add(grant_select_form.cleaned_data['grant']) publication.save() messages.success(request, 'Grant added to publication %s' % str(publication)) - return redirect(reverse('journals:manage_metadata')) + return redirect(reverse('journals:manage_metadata', + kwargs={'doi_label': publication.doi_label})) + + +@permission_required('scipost.can_publish_accepted_submission', return_403=True) +@transaction.atomic +def add_generic_funder(request, doi_label): + """ + Called by an Editorial Administrator. + This associates a funder (generic, not via grant) from the database to this publication. + """ + publication = get_object_or_404(Publication, doi_label=doi_label) + funder_select_form = FunderSelectForm(request.POST or None) + if funder_select_form.is_valid(): + publication.funders_generic.add(funder_select_form.cleaned_data['funder']) + publication.save() + messages.success(request, 'Generic funder added to publication %s' % str(publication)) + return redirect(reverse('journals:manage_metadata', + kwargs={'doi_label': doi_label})) @permission_required('scipost.can_publish_accepted_submission', return_403=True) @@ -453,7 +486,8 @@ def create_metadata_xml(request, doi_label): if create_metadata_xml_form.is_valid(): create_metadata_xml_form.save() messages.success(request, 'Metadata XML saved') - return redirect(reverse('journals:manage_metadata')) + return redirect(reverse('journals:manage_metadata', + kwargs={'doi_label': doi_label})) # create a doi_batch_id salt = "" @@ -471,7 +505,8 @@ def create_metadata_xml(request, doi_label): 'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' 'xmlns:fr="http://www.crossref.org/fundref.xsd" ' 'xsi:schemaLocation="http://www.crossref.org/schema/4.4.0 ' - 'http://www.crossref.org/shema/deposit/crossref4.4.0.xsd">\n' + 'http://www.crossref.org/shema/deposit/crossref4.4.0.xsd" ' + 'xmlns:ai="http://www.crossref.org/AccessIndicators.xsd">\n' '<head>\n' '<doi_batch_id>' + str(doi_batch_id) + '</doi_batch_id>\n' '<timestamp>' + timezone.now().strftime('%Y%m%d%H%M%S') + '</timestamp>\n' @@ -561,10 +596,11 @@ def create_metadata_xml(request, doi_label): '<crossmark_domain><domain>scipost.org</domain></crossmark_domain>\n' '</crossmark_domains>\n' '<crossmark_domain_exclusive>false</crossmark_domain_exclusive>\n' - '<custom_metadata>\n' ) - funders = Funder.objects.filter(grant__in=publication.grants.all()).distinct() + funders = (Funder.objects.filter(grant__in=publication.grants.all()) + | publication.funders_generic.all()).distinct() nr_funders = funders.count() + initial['metadata_xml'] += '<custom_metadata>\n' if nr_funders > 0: initial['metadata_xml'] += '<fr:program name="fundref">\n' for funder in funders: @@ -583,9 +619,14 @@ def create_metadata_xml(request, doi_label): if nr_funders > 1: initial['metadata_xml'] += '</fr:assertion>\n' initial['metadata_xml'] += '</fr:program>\n' - initial['metadata_xml'] += ( - '</custom_metadata>\n' + '<ai:program name="AccessIndicators">\n' + '<ai:license_ref>' + publication.get_cc_license_URI() + + '</ai:license_ref>\n' + '</ai:program>\n' + ) + initial['metadata_xml'] += '</custom_metadata>\n' + initial['metadata_xml'] += ( '</crossmark>\n' '<archive_locations><archive name="CLOCKSS"></archive></archive_locations>\n' '<doi_data>\n' @@ -596,6 +637,10 @@ def create_metadata_xml(request, doi_label): '<resource>https://scipost.org/' + publication.doi_string + '/pdf</resource>\n' '</item></collection>\n' + '<collection property="text-mining">\n' + '<item><resource mime_type="application/pdf">' + 'https://scipost.org/' + publication.doi_string + '/pdf</resource></item>\n' + '</collection>' '</doi_data>\n' ) try: @@ -700,7 +745,8 @@ def mark_deposit_success(request, deposit_id, success): elif success == '0': deposit.deposit_successful = False deposit.save() - return redirect(reverse('journals:manage_metadata')) + return redirect(reverse('journals:manage_metadata', + kwargs={'doi_label': deposit.publication.doi_label})) @permission_required('scipost.can_publish_accepted_submission', return_403=True) @@ -829,7 +875,8 @@ 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(reverse('journals:harvest_all_publications')) + return redirect(reverse('journals:manage_metadata', + kwargs={'doi_label': doi_label})) response_headers = r.headers response_text = r.text response_deserialized = ET.fromstring(r.text) diff --git a/scipost/admin.py b/scipost/admin.py index 21a0de1351f583a3073d8292ca7df866b37d9f01..36831284095a32ab06999a534bec999cd713bb46 100644 --- a/scipost/admin.py +++ b/scipost/admin.py @@ -183,6 +183,14 @@ def college_fellow_is_active(fellow): '''Check if fellow is currently active.''' return fellow.is_active() +class EditorialCollegeFellowshipAdminForm(forms.ModelForm): + contributor = forms.ModelChoiceField( + queryset=Contributor.objects.order_by('user__last_name')) + + class Meta: + model = EditorialCollegeFellowship + fields = '__all__' + class EditorialCollegeFellowshipAdmin(admin.ModelAdmin): list_display = ('__str__', 'college', college_fellow_is_active) @@ -192,6 +200,7 @@ class EditorialCollegeFellowshipAdmin(admin.ModelAdmin): fields = ('contributor', 'college', 'start_date', 'until_date', 'affiliation', ) college_fellow_is_active.boolean = True + form = EditorialCollegeFellowshipAdminForm admin.site.register(EditorialCollegeFellowship, EditorialCollegeFellowshipAdmin) diff --git a/submissions/views.py b/submissions/views.py index ff3cbadb075c9de3046e30f4b55e67def1b29285..8d5955b8d97c259bce6283ae745a10da1cbf6579 100644 --- a/submissions/views.py +++ b/submissions/views.py @@ -883,7 +883,7 @@ def decline_ref_invitation(request, invitation_key): invitation.submission.add_event_for_author('A referee has declined the' ' refereeing invitation.') invitation.submission.add_event_for_eic('Referee %s has declined the refereeing ' - 'invitation.' % invitation.referee.user.last_name) + 'invitation.' % invitation.last_name) messages.success(request, 'Thank you for informing us that you will not provide a Report.') return redirect(reverse('scipost:index'))