Newer
Older
'<anonymous sequence="first" contributor_role="'
+ relation_to_published['contributor_role'] + '"/>'
else:
metadata_xml += (
'<person_name sequence="first" contributor_role="'
+ relation_to_published['contributor_role'] + '">'
'<given_name>' + _object.author.user.first_name + '</given_name>'
'<surname>' + _object.author.user.last_name + '</surname>'
'</person_name>\n'
)
if isinstance(_object, Publication):
url_to_declare = 'https://scipost.org{}'.format(_object.get_absolute_url())
else:
url_to_declare = 'https://scipost.org/{}'.format(_object.doi_label)
metadata_xml += (
'</contributors>\n'
'<titles><title>' + relation_to_published['title'] + '</title></titles>\n'
'<month>' + _object.date_submitted.strftime('%m') + '</month>'
'<day>' + _object.date_submitted.strftime('%d') + '</day>'
'<year>' + _object.date_submitted.strftime('%Y') + '</year>'
'</review_date>\n'
'<program xmlns="http://www.crossref.org/relations.xsd">\n'
'<related_item>'
'<description>' + relation_to_published['title'] + '</description>\n'
'<inter_work_relation relationship-type="isReviewOf" identifier-type="doi">'
+ relation_to_published['isReviewOfDOI'] + '</inter_work_relation></related_item>\n'
'</program>'
'<doi_data><doi>' + _object.doi_string + '</doi>\n'
'</resource></doi_data>\n'
'</peer_review>\n'
'</body>\n'
'</doi_batch>\n'
)
else:
metadata_xml += (
'<body>\n'
'<database>\n'
'<database_metadata language="en">\n'
'<titles><title>SciPost Reports and Comments</title></titles>\n'
'</database_metadata>\n'
'<dataset dataset_type="collection">\n'
'<doi_data><doi>' + _object.doi_string + '</doi>\n'
'<resource>https://scipost.org' + _object.get_absolute_url() +
'</resource></doi_data>\n'
'</dataset></database>\n'
'</body></doi_batch>'
# CAUTION: Debug is False, production goes for real deposit!!!
url = 'http://doi.crossref.org/servlet/deposit'
else:
url = 'http://test.crossref.org/servlet/deposit'
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
params = {
'operation': 'doMDUpload',
'login_id': settings.CROSSREF_LOGIN_ID,
'login_passwd': settings.CROSSREF_LOGIN_PASSWORD,
}
files = {'fname': ('metadata.xml', metadata_xml, 'multipart/form-data')}
r = requests.post(url, params=params, files=files)
deposit = GenericDOIDeposit(content_type=ContentType.objects.get_for_model(_object),
object_id=object_id,
content_object=_object,
timestamp=timestamp,
doi_batch_id=doi_batch_id,
metadata_xml=metadata_xml,
deposition_date=timezone.now(),
response=r.text)
deposit.save()
context = {
'response_headers': r.headers,
'response_text': r.text,
}
return render(request, 'journals/generic_metadata_xml_deposit.html', context)
@permission_required('scipost.can_publish_accepted_submission', return_403=True)
def mark_generic_deposit_success(request, deposit_id, success):
deposit = get_object_or_404(GenericDOIDeposit, pk=deposit_id)
if success == '1':
deposit.deposit_successful = True
deposit.content_object.doideposit_needs_updating = False
deposit.content_object.save()
elif success == '0':
deposit.deposit_successful = False
deposit.save()
if deposit.content_type.name == 'report':
return redirect(reverse('journals:manage_report_metadata'))
else:
return redirect(reverse('journals:manage_comment_metadata'))
@permission_required('scipost.can_publish_accepted_submission', return_403=True)
def email_object_made_citable(request, **kwargs):
"""
This method sends an email to the author of a Report or a Comment,
to notify that the object has been made citable (doi registered).
"""
type_of_object = kwargs['type_of_object']
object_id = int(kwargs['object_id'])
if type_of_object == 'report':
_object = get_object_or_404(Report, id=object_id)
accepted_submission__arxiv_identifier_wo_vn_nr=_object.submission.arxiv_identifier_wo_vn_nr)
publication_citation = publication.citation
publication_doi = publication.doi_string
except Publication.DoesNotExist:
pass
elif type_of_object == 'comment':
_object = get_object_or_404(Comment, id=object_id)
redirect_to = reverse('journals:manage_comment_metadata')
else:
raise Http404
if not _object.doi_label:
messages.warning(request, 'This object does not have a DOI yet.')
return redirect(redirect_to)
if type_of_object == 'report':
JournalUtils.load({'report': _object,
'publication_citation': publication_citation,
'publication_doi': publication_doi})
JournalUtils.email_report_made_citable()
else:
JournalUtils.load({'comment': _object, })
JournalUtils.email_comment_made_citable()
messages.success(request, 'Email sent')
return redirect(redirect_to)
###########
# Viewing #
###########
def report_detail(request, doi_label):
report = get_object_or_404(Report.objects.accepted(), doi_label=doi_label)
return redirect(report.get_absolute_url())
def comment_detail(request, doi_label):
comment = get_object_or_404(Comment.objects.vetted().regular_comments(), doi_label=doi_label)
return redirect(comment.get_absolute_url())
def author_reply_detail(request, doi_label):
comment = get_object_or_404(Comment.objects.vetted().author_replies(), doi_label=doi_label)
return redirect(comment.get_absolute_url())
def publication_detail(request, doi_label):
"""
The actual Publication detail page. This is visible for everyone if published or
visible for Production Supervisors and Administrators if in draft.
"""
publication = get_object_or_404(Publication, doi_label=doi_label)
if not publication.is_published and not publication.status == PUBLICATION_PREPUBLISHED:
if not request.user.has_perm('scipost.can_draft_publication'):
raise Http404('Publication is not publicly visible')
if publication.in_issue:
journal = publication.in_issue.in_volume.in_journal
elif publication.in_journal:
journal = publication.in_journal
else:
raise Http404('Publication configuration is valid')
context = {
'publication': publication,
return render(request, 'journals/publication_detail.html', context)
def publication_detail_pdf(request, doi_label):
"""
The actual Publication pdf. This is visible for everyone if published or
visible for Production Supervisors and Administrators if in draft.
"""
publication = get_object_or_404(Publication, doi_label=doi_label)
if not publication.is_published and not request.user.has_perm('scipost.can_draft_publication'):
raise Http404('Publication is not publicly visible')
response = HttpResponse(publication.pdf_file.read(), content_type='application/pdf')
response['Content-Disposition'] = ('filename='
+ publication.doi_label.replace('.', '_') + '.pdf')
######################
# Feed DOIs to arXiv #
######################
def arxiv_doi_feed(request, doi_label):
"""
This method provides arXiv with the doi and journal ref of the 100 most recent
publications in the journal specified by doi_label.
"""
journal = get_object_or_404(Journal, doi_label=doi_label)
feedxml = ('<preprint xmlns="http://arxiv.org/doi_feed" '
'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" '
'identifier="SciPost.org ' + doi_label + ' arXiv.org DOI feed" '
'version="DOI SnappyFeed v1.0" '
'xsi:schemaLocation="http://arxiv.org/doi_feed '
'http://arxiv.org/schemas/doi_feed.xsd">')
now = timezone.now()
feedxml += '<date year="%s" month="%s" day="%s" />' % (now.strftime('%Y'),
now.strftime('%m'), now.strftime('%d'))
publications = Publication.objects.filter(
in_issue__in_volume__in_journal=journal).order_by('-publication_date')[:100]
for publication in publications:
feedxml += ('\n<article preprint_id="%s" doi="%s" journal_ref="%s" />' % (
publication.accepted_submission.arxiv_identifier_wo_vn_nr, publication.doi_string,
feedxml += '\n</preprint>'
return HttpResponse(feedxml, content_type='text/xml')