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/models.py b/journals/models.py index 30c7664fada98b207ed7dac8d32480bd1b9d860d..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 @@ -169,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/views.py b/journals/views.py index ab59c37ec41ebfb71989cf0d291723df041a45e3..083d6e3457174551c475ed5921c83c22cae1a273 100644 --- a/journals/views.py +++ b/journals/views.py @@ -505,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' @@ -599,9 +600,7 @@ def create_metadata_xml(request, doi_label): funders = (Funder.objects.filter(grant__in=publication.grants.all()) | publication.funders_generic.all()).distinct() nr_funders = funders.count() - need_custom_metadata = nr_funders > 0 # JSC: more conditions to follow later - if need_custom_metadata: - initial['metadata_xml'] += '<custom_metadata>\n' + initial['metadata_xml'] += '<custom_metadata>\n' if nr_funders > 0: initial['metadata_xml'] += '<fr:program name="fundref">\n' for funder in funders: @@ -620,8 +619,13 @@ def create_metadata_xml(request, doi_label): if nr_funders > 1: initial['metadata_xml'] += '</fr:assertion>\n' initial['metadata_xml'] += '</fr:program>\n' - if need_custom_metadata: - initial['metadata_xml'] += '</custom_metadata>\n' + initial['metadata_xml'] += ( + '<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' @@ -633,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: