Example #1
0
def contact(url_seg):

    if not request.is_xhr:
        abort(403, _('Requisição inválida, deve ser ajax.'))

    if utils.is_recaptcha_valid(request):

        form = forms.ContactForm(request.form)

        journal = controllers.get_journal_by_url_seg(url_seg)

        if not journal.enable_contact:
            abort(403, _('Periódico não permite envio de email.'))

        recipients = journal.editor_email

        if form.validate():
            sent, message = controllers.send_email_contact(recipients,
                                                           form.data['name'],
                                                           form.data['your_email'],
                                                           form.data['message'])

            return jsonify({'sent': sent, 'message': str(message),
                            'fields': [key for key in form.data.keys()]})

        else:
            return jsonify({'sent': False, 'message': form.errors,
                            'fields': [key for key in form.data.keys()]})

    else:
        abort(400, _('Requisição inválida, captcha inválido.'))
Example #2
0
def form_contact(url_seg):
    journal = controllers.get_journal_by_url_seg(url_seg)
    if not journal:
        abort(404, _('Periódico não encontrado'))

    context = {'journal': journal}
    return render_template("journal/includes/contact_form.html", **context)
Example #3
0
def issue_grid(url_seg):
    journal = controllers.get_journal_by_url_seg(url_seg)

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

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

    # idioma da sessão
    language = session.get('lang', get_locale())

    # A ordenação padrão da função ``get_issues_by_jid``: "-year", "-volume", "-order"
    issues_data = controllers.get_issues_for_grid_by_jid(journal.id, is_public=True)
    latest_issue = issues_data['last_issue']
    if latest_issue:
        latest_issue_legend = descriptive_short_format(
            title=latest_issue.journal.title, short_title=latest_issue.journal.short_title,
            pubdate=str(latest_issue.year), volume=latest_issue.volume, number=latest_issue.number,
            suppl=latest_issue.suppl_text, language=language[:2].lower())
    else:
        latest_issue_legend = None

    context = {
        'journal': journal,
        'next_issue': None,
        'previous_issue': issues_data['previous_issue'],
        'last_issue': issues_data['last_issue'],
        'latest_issue_legend': latest_issue_legend,
        'volume_issue': issues_data['volume_issue'],
        'ahead': issues_data['ahead'],
        'result_dict': issues_data['ordered_for_grid'],
    }

    return render_template("issue/grid.html", **context)
Example #4
0
def pressrelease(url_seg, url_seg_issue, url_seg_article, lang_code):
    journal = controllers.get_journal_by_url_seg(url_seg)

    issue = controllers.get_issue_by_url_seg(journal.url_segment, url_seg_issue)

    if url_seg_article:
        article = controllers.get_article_by_url_seg(url_seg_article)
    else:
        article = None

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

    if not issue:
        abort(404, _('Fascículo não encontrado'))

    press_release = controllers.get_press_release(journal, issue, lang_code, article)

    if not press_release:
        abort(404, _('Press Release não encontrado'))

    context = {
        'press_release': press_release
    }

    return render_template("includes/press_release.html", **context)
Example #5
0
def about_journal(url_seg):
    language = session.get('lang', get_locale())

    journal = controllers.get_journal_by_url_seg(url_seg)

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

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

    # A ordenação padrão da função ``get_issues_by_jid``: "-year", "-volume", "order"
    issues = controllers.get_issues_by_jid(journal.id, is_public=True)

    latest_issue = issues[0] if issues else None

    if latest_issue:
        latest_issue_legend = descriptive_short_format(
            title=latest_issue.journal.title,
            short_title=latest_issue.journal.short_title,
            pubdate=str(latest_issue.year),
            volume=latest_issue.volume,
            number=latest_issue.number,
            suppl=latest_issue.suppl_text,
            language=language[:2].lower())
    else:
        latest_issue_legend = None

    # A lista de números deve ter mais do que 1 item para que possamos tem
    # anterior e próximo
    if len(issues) >= 2:
        previous_issue = issues[1]
    else:
        previous_issue = None

    page = controllers.get_page_by_journal_acron_lang(journal.acronym,
                                                      language)

    context = {
        'next_issue': None,
        'previous_issue': previous_issue,
        'journal': journal,
        'latest_issue_legend': latest_issue_legend,
        'last_issue': latest_issue,
    }

    if page:
        context['content'] = page.content
        if page.updated_at:
            context['page_updated_at'] = page.updated_at

    return render_template("journal/about.html", **context)
Example #6
0
def journal_detail(url_seg):
    journal = controllers.get_journal_by_url_seg(url_seg)

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

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

    # todo: ajustar para que seja só noticias relacionadas ao periódico
    default_lang = current_app.config.get('BABEL_DEFAULT_LOCALE')
    language = session.get('lang', default_lang)
    news = controllers.get_latest_news_by_lang(language)

    # A ordenação padrão da função ``get_issues_by_jid``: "-year", "-volume", "order"
    issues = controllers.get_issues_by_jid(journal.id, is_public=True)

    # A lista de fascículos deve ter mais do que 1 item para que possamos tem
    # anterior e próximo
    if len(issues) >= 2:
        previous_issue = issues[1]
    else:
        previous_issue = None

    # Press releases
    press_releases = controllers.get_press_releases({'journal': journal,
                                                     'language': language})

    # Lista de seções
    # Mantendo sempre o idioma inglês para as seções na página incial do periódico
    if journal.last_issue:
        sections = [section for section in journal.last_issue.sections if section.language == 'en']
    else:
        sections = []

    context = {
        'next_issue': None,
        'previous_issue': previous_issue,
        'journal': journal,
        'press_releases': press_releases,
        # o primiero item da lista é o último fascículo.
        # condicional para verificar se issues contém itens
        'last_issue': issues[0] if issues else None,
        'sections': sections if sections else None,
        'news': news
    }

    return render_template("journal/detail.html", **context)
Example #7
0
def journal_feed(url_seg):
    journal = controllers.get_journal_by_url_seg(url_seg)

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

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

    issues = controllers.get_issues_by_jid(journal.jid, is_public=True)
    last_issue = issues[0] if issues else None
    articles = controllers.get_articles_by_iid(last_issue.iid, is_public=True)

    feed = AtomFeed(journal.title,
                    feed_url=request.url,
                    url=request.url_root,
                    subtitle=utils.get_label_issue(last_issue))

    # ######### TODO: Revisar/Melhorar/Consertar #########
    try:
        feed_language = session['lang'][:2].lower()
    except Exception as e:
        feed_language = 'pt'

    for article in articles:

        # ######### TODO: Revisar #########
        article_lang = feed_language
        if feed_language not in article.languages:
            article_lang = article.original_language

        feed.add(article.title or 'NO TITLE',
                 render_template("issue/feed_content.html", article=article),
                 content_type='html',
                 author=article.authors,
                 url=url_external('main.article_detail',
                                  url_seg=journal.url_segment,
                                  url_seg_issue=last_issue.url_segment,
                                  url_seg_article=article.url_segment,
                                  lang_code=article_lang),
                 updated=journal.updated,
                 published=journal.created)

    return feed.get_response()
Example #8
0
def journal_feed(url_seg):
    journal = controllers.get_journal_by_url_seg(url_seg)

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

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

    issues = controllers.get_issues_by_jid(journal.jid, is_public=True)
    last_issue = issues[0] if issues else None
    articles = controllers.get_articles_by_iid(last_issue.iid, is_public=True)

    feed = AtomFeed(journal.title,
                    feed_url=request.url,
                    url=request.url_root,
                    subtitle=utils.get_label_issue(last_issue))

    feed_language = session.get('lang', get_locale())
    feed_language = feed_language[:2].lower()

    for article in articles:

        # ######### TODO: Revisar #########
        article_lang = feed_language
        if feed_language not in article.languages:
            article_lang = article.original_language

        feed.add(article.title or _('Artigo sem título'),
                 render_template("issue/feed_content.html", article=article),
                 content_type='html',
                 id=article.doi or article.pid,
                 author=article.authors,
                 url=url_external('main.article_detail',
                                  url_seg=journal.url_segment,
                                  url_seg_issue=last_issue.url_segment,
                                  url_seg_article=article.url_segment,
                                  lang_code=article_lang),
                 updated=journal.updated,
                 published=journal.created)

    return feed.get_response()
Example #9
0
def issue_grid(url_seg):
    journal = controllers.get_journal_by_url_seg(url_seg)

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

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

    # A ordenação padrão da função ``get_issues_by_jid``: "-year", "-volume", "-order"
    issues_data = controllers.get_issues_for_grid_by_jid(journal.id, is_public=True)

    context = {
        "journal": journal,
        "next_issue": None,
        "previous_issue": issues_data["previous_issue"],
        "last_issue": issues_data["last_issue"],
        "volume_issue": issues_data["volume_issue"],
        "ahead": issues_data["ahead"],
        "result_dict": issues_data["ordered_for_grid"],
    }
    return render_template("issue/grid.html", **context)
Example #10
0
def journal_feed(url_seg):
    journal = controllers.get_journal_by_url_seg(url_seg)

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

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

    issues = controllers.get_issues_by_jid(journal.jid, is_public=True)
    last_issue = issues[0] if issues else None
    articles = controllers.get_articles_by_iid(last_issue.iid, is_public=True)

    feed = AtomFeed(
        journal.title, feed_url=request.url, url=request.url_root, subtitle=utils.get_label_issue(last_issue)
    )

    # ######### TODO: Revisar/Melhorar/Consertar #########
    try:
        feed_language = session["lang"][:2].lower()
    except Exception, e:
        feed_language = "pt"
Example #11
0
def journal_detail(url_seg):
    journal = controllers.get_journal_by_url_seg(url_seg)

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

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

    # todo: ajustar para que seja só noticias relacionadas ao periódico
    default_lang = current_app.config.get("BABEL_DEFAULT_LOCALE")
    language = session.get("lang", default_lang)
    news = controllers.get_latest_news_by_lang(language)

    # A ordenação padrão da função ``get_issues_by_jid``: "-year", "-volume", "order"
    issues = controllers.get_issues_by_jid(journal.id, is_public=True)

    # A lista de fascículos deve ter mais do que 1 item para que possamos tem
    # anterior e próximo
    if len(issues) >= 2:
        previous_issue = issues[1]
    else:
        previous_issue = None

    # Get press releases
    press_releases = controllers.get_press_releases({"journal": journal, "language": language})

    context = {
        "next_issue": None,
        "previous_issue": previous_issue,
        "journal": journal,
        "press_releases": press_releases,
        # o primiero item da lista é o último fascículo.
        # condicional para verificar se issues contém itens
        "last_issue": issues[0] if issues else None,
        "news": news,
    }

    return render_template("journal/detail.html", **context)
Example #12
0
def about_journal(url_seg):
    language = session.get('lang', get_locale())

    journal = controllers.get_journal_by_url_seg(url_seg)

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

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

    # A ordenação padrão da função ``get_issues_by_jid``: "-year", "-volume", "order"
    issues = controllers.get_issues_by_jid(journal.id, is_public=True)

    # A lista de números deve ter mais do que 1 item para que possamos tem
    # anterior e próximo
    if len(issues) >= 2:
        previous_issue = issues[1]
    else:
        previous_issue = None

    page = controllers.get_page_by_journal_acron_lang(journal.acronym, language)

    context = {
        'next_issue': None,
        'previous_issue': previous_issue,
        'journal': journal,
        # o primiero item da lista é o último número.
        # condicional para verificar se issues contém itens
        'last_issue': issues[0] if issues else None,
    }

    if page:
        context['content'] = page.content
        if page.updated_at:
            context['page_updated_at'] = page.updated_at

    return render_template("journal/about.html", **context)
Example #13
0
def issue_grid(url_seg):
    journal = controllers.get_journal_by_url_seg(url_seg)

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

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

    # A ordenação padrão da função ``get_issues_by_jid``: "-year", "-volume", "-order"
    issues_data = controllers.get_issues_for_grid_by_jid(journal.id, is_public=True)

    context = {
        'journal': journal,
        'next_issue': None,
        'previous_issue': issues_data['previous_issue'],
        'last_issue': issues_data['last_issue'],
        'volume_issue': issues_data['volume_issue'],
        'ahead': issues_data['ahead'],
        'result_dict': issues_data['ordered_for_grid'],
    }

    return render_template("issue/grid.html", **context)
Example #14
0
def about_journal(url_seg):
    default_lang = current_app.config.get("BABEL_DEFAULT_LOCALE")
    language = session.get("lang", default_lang) or default_lang

    journal = controllers.get_journal_by_url_seg(url_seg)

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

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

    # A ordenação padrão da função ``get_issues_by_jid``: "-year", "-volume", "order"
    issues = controllers.get_issues_by_jid(journal.id, is_public=True)

    # A lista de fascículos deve ter mais do que 1 item para que possamos tem
    # anterior e próximo
    if len(issues) >= 2:
        previous_issue = issues[1]
    else:
        previous_issue = None

    page = controllers.get_page_by_journal_acron_lang(journal.acronym, language)

    context = {
        "next_issue": None,
        "previous_issue": previous_issue,
        "journal": journal,
        # o primiero item da lista é o último fascículo.
        # condicional para verificar se issues contém itens
        "last_issue": issues[0] if issues else None,
    }

    if page:
        context["content"] = page.content

    return render_template("journal/about.html", **context)
Example #15
0
def journal_detail(url_seg):
    journal = controllers.get_journal_by_url_seg(url_seg)

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

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

    # todo: ajustar para que seja só noticias relacionadas ao periódico
    language = session.get('lang', get_locale())
    news = controllers.get_latest_news_by_lang(language)

    # A ordenação padrão da função ``get_issues_by_jid``: "-year", "-volume", "order"
    issues = controllers.get_issues_by_jid(journal.id, is_public=True)

    # A lista de números deve ter mais do que 1 item para que possamos tem
    # anterior e próximo
    if len(issues) >= 2:
        previous_issue = issues[1]
    else:
        previous_issue = None

    # Press releases
    press_releases = controllers.get_press_releases({
        'journal': journal,
        'language': language
    })

    # Lista de seções
    # Mantendo sempre o idioma inglês para as seções na página incial do periódico
    if journal.last_issue and journal.current_status == "current":
        sections = [
            section for section in journal.last_issue.sections
            if section.language == 'en'
        ]
        recent_articles = controllers.get_recent_articles_of_issue(
            journal.last_issue.iid, is_public=True)
    else:
        sections = []
        recent_articles = []

    if len(issues) > 0:
        latest_issue = issues[0]
        latest_issue_legend = descriptive_short_format(
            title=latest_issue.journal.title,
            short_title=latest_issue.journal.short_title,
            pubdate=str(latest_issue.year),
            volume=latest_issue.volume,
            number=latest_issue.number,
            suppl=latest_issue.suppl_text,
            language=language[:2].lower())
    else:
        latest_issue = None
        latest_issue_legend = ''

    context = {
        'next_issue':
        None,
        'previous_issue':
        previous_issue,
        'journal':
        journal,
        'press_releases':
        press_releases,
        'recent_articles':
        recent_articles,
        'journal_study_areas': [
            STUDY_AREAS.get(study_area.upper())
            for study_area in journal.study_areas
        ],
        # o primiero item da lista é o último número.
        # condicional para verificar se issues contém itens
        'last_issue':
        latest_issue,
        'latest_issue_legend':
        latest_issue_legend,
        'sections':
        sections if sections else None,
        'news':
        news
    }

    return render_template("journal/detail.html", **context)