コード例 #1
0
ファイル: views.py プロジェクト: pixelandpen/janeway
def download_galley(request, article_id, galley_id):
    """ Serves a galley file for an article

    :param request: an HttpRequest object
    :param article_id: an Article object PK
    :param galley_id: an Galley object PK
    :return: a streaming response of the requested file or a 404.
    """
    article = get_object_or_404(submission_models.Article, pk=article_id)
    galley = get_object_or_404(core_models.Galley, pk=galley_id)

    store_article_access(request, article, 'download', galley_type=galley.file.label)
    return files.serve_file(request, galley.file, article)
コード例 #2
0
ファイル: views.py プロジェクト: mjlavin80/janeway
def preprints_article(request, article_id):
    """
    Fetches a single article and displays its metadata
    :param request: HttpRequest
    :param article_id: integer, PK of an Article object
    :return: HttpResponse or Http404 if object not found
    """
    article = get_object_or_404(
        submission_models.Article.preprints.prefetch_related('authors'),
        pk=article_id,
        stage=submission_models.STAGE_PREPRINT_PUBLISHED,
        date_published__lte=timezone.now())
    comments = models.Comment.objects.filter(article=article, is_public=True)
    form = forms.CommentForm()

    if request.POST:

        if not request.user.is_authenticated:
            messages.add_message(request, messages.WARNING,
                                 'You must be logged in to comment')
            return redirect(reverse('core_login'))

        form = forms.CommentForm(request.POST)

        if form.is_valid():
            comment = form.save(commit=False)
            preprint_logic.handle_comment_post(request, article, comment)
            return redirect(
                reverse('preprints_article', kwargs={'article_id':
                                                     article_id}))

    pdf = preprint_logic.get_pdf(article)
    html = preprint_logic.get_html(article)
    store_article_access(request, article, 'view')

    template = 'preprints/article.html'
    context = {
        'article': article,
        'galleys': article.galley_set.all(),
        'pdf': pdf,
        'html': html,
        'comments': comments,
        'form': form,
    }

    return render(request, template, context)
コード例 #3
0
ファイル: views.py プロジェクト: oncomouse/janeway
def article(request, identifier_type, identifier):
    """ Renders an article.

    :param request: the request associated with this call
    :param identifier_type: the identifier type
    :param identifier: the identifier
    :return: a rendered template of the article
    """
    article_object = submission_models.Article.get_article(
        request.journal, identifier_type, identifier)
    """
    logger.add_entry(types='Info',
                     description='Article hit for identifier {0} of type {1}'.format(identifier, identifier_type),
                     level='Info', actor=None, target=article_object)
    """

    content = None
    galleys = article_object.galley_set.all()

    # check if there is a galley file attached that needs rendering
    if article_object.stage == submission_models.STAGE_PUBLISHED:
        content = list_galleys(article_object, galleys)
    else:
        article_object.abstract = "This is an accepted article with a DOI pre-assigned that is not yet published."

    if not article_object.large_image_file or article_object.large_image_file.uuid_filename == '':
        article_object.large_image_file = core_models.File()
        # assign the default image with a hacky patch
        # TODO: this should be set to a journal-wide setting
        article_object.large_image_file.uuid_filename = "carousel1.png"
        article_object.large_image_file.is_remote = True

    store_article_access(request, article_object, 'view')

    template = 'journal/article.html'
    context = {
        'article': article_object,
        'galleys': galleys,
        'identifier_type': identifier_type,
        'identifier': identifier,
        'article_content': content
    }

    return render(request, template, context)