コード例 #1
0
ファイル: views.py プロジェクト: arturorc/opac
def article_detail_pid(pid):

    article = controllers.get_article_by_pid(pid)

    if not article:
        article = controllers.get_article_by_oap_pid(pid)

    if not article:
        abort(404, _('Artigo não encontrado'))

    return redirect(
        url_for('main.article_detail',
                url_seg=article.journal.acronym,
                url_seg_issue=article.issue.url_segment,
                url_seg_article=article.url_segment))
コード例 #2
0
ファイル: views.py プロジェクト: arturorc/opac
def router_legacy():

    script_php = request.args.get('script', None)
    pid = request.args.get('pid', None)
    allowed_scripts = [
        'sci_serial', 'sci_issuetoc', 'sci_arttext', 'sci_abstract',
        'sci_issues', 'sci_pdf'
    ]
    if (script_php is not None) and (script_php
                                     in allowed_scripts) and not pid:
        # se tem pelo menos um param: pid ou script_php
        abort(
            400,
            _(u'Requsição inválida ao tentar acessar o artigo com pid: %s' %
              pid))
    elif script_php and pid:

        if script_php == 'sci_serial':
            # pid = issn
            journal = controllers.get_journal_by_issn(pid)

            if not journal:
                abort(404, _('Periódico não encontrado'))

            if not journal.is_public:
                abort(404, JOURNAL_UNPUBLISH + _(journal.unpublish_reason))

            return journal_detail(journal.url_segment)

        elif script_php == 'sci_issuetoc':

            issue = controllers.get_issue_by_pid(pid)

            if not issue:
                abort(404, _('Número não encontrado'))

            if not issue.is_public:
                abort(404, ISSUE_UNPUBLISH + _(issue.unpublish_reason))

            if not issue.journal.is_public:
                abort(404,
                      JOURNAL_UNPUBLISH + _(issue.journal.unpublish_reason))

            return issue_toc(issue.journal.url_segment, issue.url_segment)

        elif script_php == 'sci_arttext' or script_php == 'sci_abstract':

            article = controllers.get_article_by_pid(pid)

            if not article:
                article = controllers.get_article_by_oap_pid(pid)

            if not article:
                abort(404, _('Artigo não encontrado'))

            if not article.is_public:
                abort(404, ARTICLE_UNPUBLISH + _(article.unpublish_reason))

            if not article.issue.is_public:
                abort(404, ISSUE_UNPUBLISH + _(article.issue.unpublish_reason))

            if not article.journal.is_public:
                abort(404,
                      JOURNAL_UNPUBLISH + _(article.journal.unpublish_reason))

            return article_detail(article.journal.url_segment,
                                  article.issue.url_segment,
                                  article.url_segment)

        elif script_php == 'sci_issues':

            journal = controllers.get_journal_by_issn(pid)

            if not journal:
                abort(404, _('Periódico não encontrado'))

            if not journal.is_public:
                abort(404, JOURNAL_UNPUBLISH + _(journal.unpublish_reason))

            return issue_grid(journal.url_segment)

        elif script_php == 'sci_pdf':
            # accesso ao pdf do artigo:
            article = controllers.get_article_by_pid(pid)

            if not article:
                article = controllers.get_article_by_oap_pid(pid)

            if not article:
                abort(404, _('Artigo não encontrado'))

            if not article.is_public:
                abort(404, ARTICLE_UNPUBLISH + _(article.unpublish_reason))

            if not article.issue.is_public:
                abort(404, ISSUE_UNPUBLISH + _(article.issue.unpublish_reason))

            if not article.journal.is_public:
                abort(404,
                      JOURNAL_UNPUBLISH + _(article.journal.unpublish_reason))

            return article_detail_pdf(article.journal.url_segment,
                                      article.issue.url_segment,
                                      article.url_segment)

        else:
            abort(
                400,
                _(u'Requsição inválida ao tentar acessar o artigo com pid: %s'
                  % pid))

    else:
        return redirect('/')