"README.rst" did not exist on "f84c7c13fa7c413bebcc7c33619ad45f9712fb91"
Newer
Older
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')