Esempio n. 1
0
def home_view(request):
    locale = l10n_utils.get_locale(request)
    donate_params = settings.DONATE_PARAMS.get(
        locale, settings.DONATE_PARAMS['en-US'])

    # presets are stored as a string but, for the home banner
    # we need it as a list.
    donate_params['preset_list'] = donate_params['presets'].split(',')
    ctx = {
        'donate_params': donate_params,
        'pocket_articles': PocketArticle.objects.all()[:4]
    }

    if locale.startswith('en-'):
        template_name = 'mozorg/home/home-en.html'
        ctx['page_content_cards'] = get_page_content_cards('home-2019', 'en-US')
    elif locale == 'de':
        template_name = 'mozorg/home/home-de.html'
        ctx['page_content_cards'] = get_page_content_cards('home-de', 'de')
    elif locale == 'fr':
        template_name = 'mozorg/home/home-fr.html'
        ctx['page_content_cards'] = get_page_content_cards('home-fr', 'fr')
    else:
        template_name = 'mozorg/home/home.html'

    return l10n_utils.render(request, template_name, ctx)
Esempio n. 2
0
def home_view(request):
    locale = l10n_utils.get_locale(request)
    donate_params = settings.DONATE_PARAMS.get(locale,
                                               settings.DONATE_PARAMS["en-US"])

    # make sure we POST to a know locale, to avoid 404 errors.
    donate_locale = locale if locale in settings.DONATE_PARAMS else "en-US"

    # presets are stored as a string but, for the home banner
    # we need it as a list.
    donate_params["preset_list"] = donate_params["presets"].split(",")
    ctx = {
        "donate_locale": donate_locale,
        "donate_params": donate_params,
        "pocket_articles": PocketArticle.objects.all()[:4],
        "ftl_files": ["mozorg/home", "mozorg/home-mr2-promo"],
        "add_active_locales": ["de", "fr"],
    }

    if locale.startswith("en-"):
        if switch("contentful-homepage-en"):
            try:
                template_name = "mozorg/home/home-contentful.html"
                # TODO: use a better system to get the pages than the ID
                ctx.update(
                    ContentfulEntry.objects.get_page_by_id(
                        content_id=settings.CONTENTFUL_HOMEPAGE_LOOKUP["en-US"]
                    ))
            except Exception as ex:
                capture_exception(ex)
                # if anything goes wrong, use the rest-of-world home page
                template_name = "mozorg/home/home.html"
        else:
            template_name = "mozorg/home/home.html"
    elif locale == "de":
        if switch("contentful-homepage-de"):
            try:
                template_name = "mozorg/home/home-contentful.html"
                ctx.update(
                    ContentfulEntry.objects.get_page_by_id(
                        content_id=settings.CONTENTFUL_HOMEPAGE_LOOKUP["de"]))
            except Exception as ex:
                capture_exception(ex)
                # if anything goes wrong, use the old page
                template_name = "mozorg/home/home-de.html"
                ctx["page_content_cards"] = get_page_content_cards(
                    "home-de", "de")
        else:
            template_name = "mozorg/home/home-de.html"
            ctx["page_content_cards"] = get_page_content_cards("home-de", "de")
    elif locale == "fr":
        template_name = "mozorg/home/home-fr.html"
        ctx["page_content_cards"] = get_page_content_cards("home-fr", "fr")
    else:
        template_name = "mozorg/home/home.html"

    return l10n_utils.render(request, template_name, ctx)
Esempio n. 3
0
def election_with_cards(request):
    locale = l10n_utils.get_locale(request)
    ctx = {
        'page_content_cards': get_page_content_cards('election-en', locale),
        'active_locales': ['de', 'en-US']
    }

    if locale == 'de':
        template_name = 'firefox/election/index-de.html'
        ctx['page_content_cards'] = get_page_content_cards('election-de', 'de')
    else:
        template_name = 'firefox/election/index.html'
        ctx['page_content_cards'] = get_page_content_cards('election-en', 'en-US')

    return l10n_utils.render(request, template_name, ctx)
Esempio n. 4
0
def election_with_cards(request):
    locale = l10n_utils.get_locale(request)
    ctx = {
        'page_content_cards': get_page_content_cards('election-en', locale),
        'active_locales': ['de', 'en-US']
    }

    if locale == 'de':
        template_name = 'firefox/election/index-de.html'
        ctx['page_content_cards'] = get_page_content_cards('election-de', 'de')
    else:
        template_name = 'firefox/election/index.html'
        ctx['page_content_cards'] = get_page_content_cards('election-en', 'en-US')

    return l10n_utils.render(request, template_name, ctx)
Esempio n. 5
0
def home_view(request):
    locale = l10n_utils.get_locale(request)

    ctx = {'pocket_articles': PocketArticle.objects.all()[:4]}

    if locale.startswith('en-'):
        template_name = 'mozorg/home/home-en.html'
        ctx['page_content_cards'] = get_page_content_cards('home-en', 'en-US')
    elif locale == 'de':
        template_name = 'mozorg/home/home-de.html'
        ctx['page_content_cards'] = get_page_content_cards('home-de', 'de')
    elif locale == 'fr':
        template_name = 'mozorg/home/home-fr.html'
        ctx['page_content_cards'] = get_page_content_cards('home-fr', 'fr')
    else:
        template_name = 'mozorg/home/home.html'

    return l10n_utils.render(request, template_name, ctx)
Esempio n. 6
0
def home_view(request):
    locale = l10n_utils.get_locale(request)
    donate_params = settings.DONATE_PARAMS.get(
        locale, settings.DONATE_PARAMS['en-US'])

    # presets are stored as a string but, for the home banner
    # we need it as a list.
    donate_params['preset_list'] = donate_params['presets'].split(',')
    ctx = {
        'donate_params': donate_params,
        'pocket_articles': PocketArticle.objects.all()[:4]
    }

    if locale.startswith('en-'):
        template_name = 'mozorg/home/home-en.html'
        ctx['page_content_cards'] = get_page_content_cards('home-2019', 'en-US')
    elif locale == 'de':
        template_name = 'mozorg/home/home-de.html'
        ctx['page_content_cards'] = get_page_content_cards('home-de', 'de')
    else:
        template_name = 'mozorg/home/home.html'

    return l10n_utils.render(request, template_name, ctx)