Exemplo n.º 1
0
def new(request):
    # Remove legacy query parameters (Bug 1236791)
    if request.GET.get('product', None) or request.GET.get('os', None):
        return HttpResponsePermanentRedirect(reverse('firefox.new'))

    scene = request.GET.get('scene', None)
    context = {
        'version': 'none',
    }

    # animation triggered for ?v=1 via data attribute in template
    if request.GET.get('v', '') == '1':
        context['version'] = '1'

    if scene == '2':
        if lang_file_is_active('firefox/new/horizon', l10n_utils.get_locale(request)):
            template = 'firefox/new/horizon/scene2.html'
        else:
            template = 'firefox/new/scene2.html'
    # if no/incorrect scene specified, show scene 1
    else:
        if lang_file_is_active('firefox/new/horizon', l10n_utils.get_locale(request)):
                template = 'firefox/new/horizon/scene1.html'
        else:
            template = 'firefox/new/scene1.html'

    return l10n_utils.render(request, template, context)
Exemplo n.º 2
0
 def get_context_data(self, **kwargs):
     ctx = super(HomeTestView, self).get_context_data(**kwargs)
     ctx['has_contribute'] = lang_file_is_active('mozorg/contribute',
                                                 l10n_utils.get_locale(self.request))
     locale = l10n_utils.get_locale(self.request)
     locale = locale if locale in settings.MOBILIZER_LOCALE_LINK else 'en-US'
     ctx['mobilizer_link'] = settings.MOBILIZER_LOCALE_LINK[locale]
     return ctx
Exemplo n.º 3
0
def plugincheck(request):
    template = 'mozorg/plugincheck.html'
    if lang_file_is_active('mozorg/plugincheck-redesign',
                           l10n_utils.get_locale(request)):
        template = 'mozorg/plugincheck-redesign.html'

    return l10n_utils.render(request, template)
Exemplo n.º 4
0
def email_newsletter_form(ctx, newsletters='mozilla-and-you', title=None,
                          include_country=True, include_language=True,
                          details=None, use_thankyou=True, thankyou_head=None,
                          thankyou_content=None, footer=True, process_form=True,
                          include_title=None, submit_text=None):
    request = ctx['request']
    context = ctx.get_all()

    success = bool(ctx.get('success'))
    if success and not use_thankyou:
        return

    form = ctx.get('newsletter_form', None)
    if not form:
        form = NewsletterFooterForm(newsletters, get_locale(request))

    context.update(dict(
        id=newsletters,
        title=title,
        include_country=include_country,
        include_language=include_language,
        details=details,
        use_thankyou=use_thankyou,
        thankyou_head=thankyou_head,
        thankyou_content=thankyou_content,
        footer=footer,
        include_title=include_title if include_title is not None else footer,
        form=form,
        submit_text=submit_text,
        success=success,
    ))

    html = jingo.render_to_string(request, 'newsletter/includes/form.html', context)
    return jinja2.Markup(html)
Exemplo n.º 5
0
def contribute(request, template, return_to_form):
    newsletter_form = NewsletterFooterForm('about-mozilla', l10n_utils.get_locale(request))

    contribute_success = False

    form = ContributeForm(request.POST or None, auto_id=u'id_contribute-%s')
    if form.is_valid():
        data = form.cleaned_data.copy()

        honeypot = data.pop('office_fax')

        if not honeypot:
            contribute_success = email_contribute.handle_form(request, form)
            if contribute_success:
                # If form was submitted successfully, return a new, empty
                # one.
                form = ContributeForm()
        else:
            # send back a clean form if honeypot was filled in
            form = ContributeForm()

    return l10n_utils.render(request,
                             template,
                             {'form': form,
                              'newsletter_form': newsletter_form,
                              'contribute_success': contribute_success,
                              'return_to_form': return_to_form,
                              'hide_form': hide_contrib_form(request.locale)})
Exemplo n.º 6
0
def home(request):
    locale = l10n_utils.get_locale(request)
    new_template = 'mozorg/home/home-new.html'
    if l10n_utils.template_is_active(new_template, locale):
        return new_home(request, locale=locale)
    else:
        return HomeTestView.as_view()(request)
Exemplo n.º 7
0
    def get_template_names(self):
        version = self.kwargs.get("fx_version") or ""
        locale = l10n_utils.get_locale(self.request)
        oldversion = self.request.GET.get("oldversion", "")
        # old versions of Firefox sent a prefixed version
        if oldversion.startswith("rv:"):
            oldversion = oldversion[3:]
        versions = ("29.", "30.", "31.", "32.")

        if version.startswith("33."):
            if show_10th_anniversary(version):
                if show_whatsnew_tour(oldversion):
                    template = "firefox/privacy_tour/tour.html"
                else:
                    template = "firefox/privacy_tour/no-tour.html"
            else:
                template = "firefox/australis/whatsnew-no-tour.html"
        elif version.startswith(versions):
            template = "firefox/australis/whatsnew-no-tour.html"
        elif locale in self.fxos_locales:
            template = "firefox/whatsnew-fxos.html"
        else:
            template = "firefox/whatsnew.html"

        # return a list to conform with original intention
        return [template]
Exemplo n.º 8
0
def newsletter_subscribe(request):
    if request.method == 'POST':
        newsletters = request.POST.get('newsletters', None)
        form = NewsletterFooterForm(newsletters,
                                    l10n_utils.get_locale(request),
                                    request.POST)
        errors = []
        if form.is_valid():
            data = form.cleaned_data

            kwargs = {'format': data['fmt']}
            # add optional data
            kwargs.update(dict((k, data[k]) for k in ['country',
                                                      'lang',
                                                      'source_url',
                                                      'first_name',
                                                      'last_name', ]
                               if data[k]))
            try:
                basket.subscribe(data['email'], data['newsletters'],
                                 **kwargs)
            except basket.BasketException as e:
                if e.code == basket.errors.BASKET_INVALID_EMAIL:
                    errors.append(unicode(invalid_email_address))
                else:
                    log.exception("Error subscribing %s to newsletter %s" %
                                  (data['email'], data['newsletters']))
                    errors.append(unicode(general_error))

        else:
            if 'email' in form.errors:
                errors.append(_('Please enter a valid email address'))
            if 'privacy' in form.errors:
                errors.append(_('You must agree to the privacy notice'))
            for fieldname in ('fmt', 'lang', 'country'):
                if fieldname in form.errors:
                    errors.extend(form.errors[fieldname])

        # form error messages may contain unsanitized user input
        errors = map(escape, errors)

        if request.is_ajax():
            # return JSON
            if errors:
                resp = {
                    'success': False,
                    'errors': errors,
                }
            else:
                resp = {'success': True}

            return HttpResponseJSON(resp)
        else:
            ctx = {'newsletter_form': form}
            if not errors:
                ctx['success'] = True

            return l10n_utils.render(request, 'newsletter/mozilla-and-you.html', ctx)

    return l10n_utils.render(request, 'newsletter/mozilla-and-you.html')
Exemplo n.º 9
0
    def get_template_names(self):
        locale = l10n_utils.get_locale(self.request)

        version = self.kwargs.get('version') or ''
        oldversion = self.request.GET.get('oldversion', '')
        # old versions of Firefox sent a prefixed version
        if oldversion.startswith('rv:'):
            oldversion = oldversion[3:]

        channel = detect_channel(version)
        if channel == 'alpha':
            if show_57_dev_whatsnew(version):
                template = 'firefox/developer/whatsnew.html'
            else:
                template = 'firefox/dev-whatsnew.html'
        elif channel == 'nightly':
            template = 'firefox/nightly_whatsnew.html'
        elif locale == 'id':
            template = 'firefox/whatsnew/index-lite.id.html'
        elif locale == 'zh-TW' and not version.startswith('64.'):
            template = 'firefox/whatsnew/index.zh-TW.html'
        elif version.startswith('66.'):
            template = 'firefox/whatsnew/whatsnew-fx66.html'
        elif version.startswith('65.'):
            template = 'firefox/whatsnew/whatsnew-fx65.html'
        elif version.startswith('64.'):
            template = 'firefox/whatsnew/fx64/whatsnew-fx64.html'
        elif version.startswith('63.'):
            template = 'firefox/whatsnew/whatsnew-fx63.html'
        else:
            template = 'firefox/whatsnew/index.html'

        # return a list to conform with original intention
        return [template]
Exemplo n.º 10
0
def new(request):
    # Remove legacy query parameters (Bug 1236791)
    if request.GET.get('product', None) or request.GET.get('os', None):
        return HttpResponsePermanentRedirect(reverse('firefox.new'))

    locale = l10n_utils.get_locale(request)
    scene = request.GET.get('scene', None)
    v = request.GET.get('v', '')

    if scene == '2':
        if locale == 'en-US':
            if v == '1':
                template = 'firefox/new/horizon/scene2.html'
            else:
                template = 'firefox/new/redesign/scene2.html'
        else:
            template = 'firefox/new/scene2.html'
    # if no/incorrect scene specified, show scene 1
    else:
        if locale == 'en-US':
            if v == '1':
                template = 'firefox/new/horizon/scene1.html'
            else:
                template = 'firefox/new/redesign/scene1.html'
        else:
            template = 'firefox/new/scene1.html'

    return l10n_utils.render(request, template)
Exemplo n.º 11
0
    def get_template_names(self):
        version = self.kwargs.get('version') or ''
        locale = l10n_utils.get_locale(self.request)
        oldversion = self.request.GET.get('oldversion', '')
        # old versions of Firefox sent a prefixed version
        if oldversion.startswith('rv:'):
            oldversion = oldversion[3:]
        versions = ('29.', '30.', '32.')

        if version.startswith('37.'):
            template = 'firefox/whatsnew-fx37.html'
        elif version.startswith('36.'):
            if show_36_whatsnew_tour(oldversion):
                template = 'firefox/australis/fx36/whatsnew-tour.html'
            else:
                template = 'firefox/australis/fx36/whatsnew-no-tour.html'
        elif show_34_0_5_search_template(version):
            if locale == 'en-US':
                if version.startswith('35.'):
                    min_version = '35.0'
                else:
                    min_version = '34.0'

                if show_search_whatsnew_tour(min_version, oldversion):
                    template = 'firefox/search_tour/tour-34.0.5.html'
                else:
                    template = 'firefox/search_tour/no-tour.html'
            else:
                template = 'firefox/australis/whatsnew-no-tour.html'
        elif version.startswith('34.'):
            if locale == 'en-US':
                if show_search_whatsnew_tour('34.0', oldversion):
                    template = 'firefox/search_tour/tour.html'
                else:
                    template = 'firefox/search_tour/no-tour.html'
            else:
                template = 'firefox/australis/whatsnew-no-tour.html'
        elif version.startswith('33.'):
            if show_10th_anniversary(version):
                if show_whatsnew_tour(oldversion):
                    template = 'firefox/privacy_tour/tour.html'
                else:
                    template = 'firefox/privacy_tour/no-tour.html'
            else:
                template = 'firefox/australis/whatsnew-no-tour.html'
        # show australis tour for ESR 31 updates
        elif version.startswith('31.'):
            if show_australis_whatsnew_tour(oldversion):
                template = 'firefox/australis/whatsnew-tour.html'
            else:
                template = 'firefox/australis/whatsnew-no-tour.html'
        elif version.startswith(versions):
            template = 'firefox/australis/whatsnew-no-tour.html'
        elif locale in self.fxos_locales:
            template = 'firefox/whatsnew-fxos.html'
        else:
            template = 'firefox/whatsnew.html'

        # return a list to conform with original intention
        return [template]
Exemplo n.º 12
0
    def get_template_names(self):
        version = self.kwargs.get('version') or ''
        locale = l10n_utils.get_locale(self.request)

        # variant is present for growth tests
        ctx = funnelcake_param(self.request)

        variant = ctx.get('funnelcake_id', None)

        if variant == '35' and version == '35.0.1':
            template = 'firefox/australis/growth-firstrun-test1.html'
        elif variant == '36' and version == '35.0.1':
            template = 'firefox/australis/growth-firstrun-test2.html'
        elif show_devbrowser_firstrun_or_whatsnew(version):
            if (waffle.switch_is_active('dev-edition-spring-campaign')):
                template = 'firefox/dev-firstrun-spring-campaign.html'
            else:
                template = 'firefox/dev-firstrun.html'
        elif show_38_0_5_firstrun_or_whatsnew(version):
            template = 'firefox/australis/fx38_0_5/firstrun.html'
        elif show_36_firstrun(version):
            template = 'firefox/australis/fx36/firstrun-tour.html'
        elif show_search_firstrun(version) and locale == 'en-US':
            template = 'firefox/australis/firstrun-34-tour.html'
        else:
            template = 'firefox/australis/firstrun-tour.html'

        # return a list to conform with original intention
        return [template]
Exemplo n.º 13
0
    def get_template_names(self):
        locale = l10n_utils.get_locale(self.request)
        version = self.kwargs.get('version') or ''
        oldversion = self.request.GET.get('oldversion', '')
        # old versions of Firefox sent a prefixed version
        if oldversion.startswith('rv:'):
            oldversion = oldversion[3:]

        if show_devbrowser_firstrun_or_whatsnew(version):
            template = 'firefox/dev-whatsnew.html'
        elif show_38_0_5_firstrun_or_whatsnew(version):
            has_video = LOCALE_SPRING_CAMPAIGN_VIDEOS.get(locale, False)
            has_pocket = locale in self.pocket_locales
            if has_pocket and has_video:
                template = 'firefox/whatsnew_38/whatsnew-pocket-video.html'
            elif has_video:
                template = 'firefox/whatsnew_38/whatsnew-video.html'
            elif has_pocket:
                template = 'firefox/whatsnew_38/whatsnew-pocket.html'
            else:
                template = 'firefox/australis/fx36/whatsnew-no-tour.html'
        elif version.startswith('37.'):
            template = 'firefox/whatsnew-fx37.html'
        elif version.startswith('36.'):
            if show_36_whatsnew_tour(oldversion):
                template = 'firefox/australis/fx36/whatsnew-tour.html'
            else:
                template = 'firefox/australis/fx36/whatsnew-no-tour.html'
        else:
            template = 'firefox/australis/whatsnew-no-tour.html'

        # return a list to conform with original intention
        return [template]
Exemplo n.º 14
0
    def get_template_names(self):
        locale = l10n_utils.get_locale(self.request)

        version = self.kwargs.get('version') or ''
        oldversion = self.request.GET.get('oldversion', '')
        # old versions of Firefox sent a prefixed version
        if oldversion.startswith('rv:'):
            oldversion = oldversion[3:]

        channel = detect_channel(version)
        if channel == 'alpha':
            if show_57_dev_whatsnew(version):
                    template = 'firefox/developer/whatsnew.html'
            else:
                template = 'firefox/dev-whatsnew.html'
        elif channel == 'nightly':
            template = 'firefox/nightly_whatsnew.html'
        elif show_57_whatsnew(version):
            # locale-specific templates don't seem to work for the default locale
            if locale == 'en-US':
                template = 'firefox/whatsnew/fx57/whatsnew-57.en-US.html'
            # locale-specific templates for de, en-GB, es-AR, es-CL, es-ES, es-MX,
            # fr, id, pl, pt-BR, ru, zh-CN, and zh-TW
            else:
                template = 'firefox/whatsnew/fx57/whatsnew-57.html'
        elif show_56_whatsnew(version, oldversion):
            template = 'firefox/whatsnew/whatsnew-56.html'
        else:
            template = 'firefox/whatsnew/index.html'

        # return a list to conform with original intention
        return [template]
Exemplo n.º 15
0
    def get_template_names(self):
        funnelcake = self.request.GET.get('f', '')
        locale = l10n_utils.get_locale(self.request)
        version = self.kwargs.get('version') or ''

        if detect_channel(version) == 'alpha':
            template = 'firefox/dev-firstrun.html'
        elif show_40_firstrun(version):
            # New onboarding animation funnecake
            if locale == 'en-US' and funnelcake in ['99', '100']:
                template = 'firefox/firstrun/new-firstrun.html'
            # Yahoo search retention funnelcake test
            elif locale == 'en-US' and funnelcake == '92':
                template = 'firefox/firstrun/yahoo-retention.html'
            elif locale == 'en-US' and funnelcake == '90':
                # ravioli/katie couric promo
                template = 'firefox/firstrun/ravioli.html'
            else:
                template = 'firefox/firstrun/firstrun-horizon.html'
        elif show_38_0_5_firstrun(version):
            template = 'firefox/australis/fx38_0_5/firstrun.html'
        else:
            template = 'firefox/australis/firstrun.html'

        # return a list to conform with original intention
        return [template]
Exemplo n.º 16
0
def home(request, template='mozorg/home/home.html'):
    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 takeover modal
    # we need it as a list.
    donate_params['preset_list'] = donate_params['presets'].split(',')

    if lang_file_is_active('mozorg/home/index-2016', locale):
        # check for variant - fundraising takeover
        v = request.GET.get('v', None)

        if (v == 'b'):
            template = 'mozorg/home/home-b.html'.format(v)
        else:
            template = 'mozorg/home/home.html'
    else:
        template = 'mozorg/home/home-voices.html'

    return l10n_utils.render(
        request, template, {
            'donate_params': donate_params,
            'has_contribute': lang_file_is_active('mozorg/contribute'),
            'tweets': home_tweets(locale),
            'mobilizer_link': settings.MOBILIZER_LOCALE_LINK.get(
                locale, settings.MOBILIZER_LOCALE_LINK['en-US'])})
Exemplo n.º 17
0
    def get_template_names(self):
        locale = l10n_utils.get_locale(self.request)
        version = self.kwargs.get('version') or ''
        f = self.request.GET.get('f', None)

        if detect_channel(version) == 'alpha':
            if show_57_dev_firstrun(version):
                    template = 'firefox/developer/firstrun.html'
            else:
                template = 'firefox/dev-firstrun.html'
        elif show_56_cliqz_firstrun(locale, version, f):
            template = 'firefox/firstrun/cliqz-funnelcake-119-122.html'
        elif show_57_firstrun(version):
            variant = self.request.GET.get('v', None)
            if locale == 'en-US' and variant in ['a', 'b']:
                template = 'firefox/firstrun/email-first-experiment/index-{0}.html'.format(variant)
            else:
                template = 'firefox/firstrun/firstrun_quantum.html'
        elif show_40_firstrun(version):
            template = 'firefox/firstrun/index.html'
        elif show_38_0_5_firstrun(version):
            template = 'firefox/australis/fx38_0_5/firstrun.html'
        else:
            template = 'firefox/australis/firstrun.html'

        # return a list to conform with original intention
        return [template]
Exemplo n.º 18
0
    def get_template_names(self):
        version = self.kwargs.get('version') or ''

        experience = self.request.GET.get('xv', None)
        locale = l10n_utils.get_locale(self.request)

        # for copy test
        # https://bugzilla.mozilla.org/show_bug.cgi?id=1451051
        variation = self.request.GET.get('v', None)

        if detect_channel(version) == 'alpha':
            if show_57_dev_firstrun(version):
                template = 'firefox/developer/firstrun.html'
            else:
                template = 'firefox/dev-firstrun.html'
        elif show_57_firstrun(version):
            if (switch('firefox-facebook-container-funnelcake') and locale == 'en-US' and experience == 'facebook-container'):
                template = 'firefox/firstrun/facebook-container.html'
            else:
                if locale == 'en-US' and variation in ['a', 'b', 'c', 'd']:
                    template = 'firefox/firstrun/firstrun-quantum-{}.html'.format(variation)
                else:
                    template = 'firefox/firstrun/firstrun-quantum.html'
        else:
            template = 'firefox/firstrun/index.html'

        # return a list to conform with original intention
        return [template]
Exemplo n.º 19
0
    def get_template_names(self):
        locale = l10n_utils.get_locale(self.request)
        version = self.kwargs.get("version") or ""
        oldversion = self.request.GET.get("oldversion", "")
        # old versions of Firefox sent a prefixed version
        if oldversion.startswith("rv:"):
            oldversion = oldversion[3:]

        if show_devbrowser_firstrun_or_whatsnew(version):
            template = "firefox/dev-whatsnew.html"
        elif show_42_whatsnew(version):
            template = "firefox/whatsnew_42/whatsnew.html"
        elif show_38_0_5_firstrun_or_whatsnew(version):
            has_video = LOCALE_SPRING_CAMPAIGN_VIDEOS.get(locale, False)
            has_pocket = locale in self.pocket_locales
            if has_pocket and has_video:
                template = "firefox/whatsnew_38/whatsnew-pocket-video.html"
            elif has_video:
                template = "firefox/whatsnew_38/whatsnew-video.html"
            elif has_pocket:
                template = "firefox/whatsnew_38/whatsnew-pocket.html"
            else:
                template = "firefox/australis/whatsnew.html"
        else:
            template = "firefox/australis/whatsnew.html"

        # return a list to conform with original intention
        return [template]
Exemplo n.º 20
0
    def get_template_names(self):
        version = self.kwargs.get('version') or None
        locale = l10n_utils.get_locale(self.request)
        v = self.request.GET.get('v', None)

        if (version):
            if (locale == 'en-US' and v in ONBOARDING_VARIATIONS):
                if (v == '1'):
                    # we have no '1' variation for secondrun, so just serve
                    # non-space-themed simple FxA template on the off-chance someone
                    # plays around with the URL
                    template = 'firefox/firstrun/firstrun.html'
                if (v == '2'):
                    template = 'firefox/onboarding/user-actions-mobileprivacy.html'
                elif (v in ['3', '6']):
                    template = 'firefox/onboarding/user-actions-pinsearch.html'
                elif (v == '4'):
                    template = 'firefox/onboarding/fxa-simple.html'
                elif (v == '5'):
                    template = 'firefox/onboarding/fxa-complex.html'
            else:
                # should never hit secondrun without a 'v' query param, but if so,
                # default to standard, non-space firstrun
                template = 'firefox/firstrun/firstrun.html'
        # if version missing from URL, give user old-timey australis fallback
        else:
            template = 'firefox/australis/firstrun.html'

        return [template]
Exemplo n.º 21
0
    def get_template_names(self):
        locale = l10n_utils.get_locale(self.request)

        version = self.kwargs.get('version') or ''
        oldversion = self.request.GET.get('oldversion', '')
        # old versions of Firefox sent a prefixed version
        if oldversion.startswith('rv:'):
            oldversion = oldversion[3:]

        channel = detect_channel(version)
        if channel == 'alpha':
            template = 'firefox/dev-whatsnew.html'
        elif channel == 'nightly':
            template = 'firefox/nightly_whatsnew.html'
        elif show_50_whatsnew(version):
            template = 'firefox/whatsnew/whatsnew-50.html'
        # zh-TW on 49.0 gets a special template
        elif locale == 'zh-TW' and show_49_0_whatsnew(version):
            template = 'firefox/whatsnew/whatsnew-zh-tw-49.html'
        elif show_42_whatsnew(version):
            template = 'firefox/whatsnew/whatsnew-42.html'
        else:
            template = 'firefox/australis/whatsnew.html'

        # return a list to conform with original intention
        return [template]
Exemplo n.º 22
0
 def get_template_names(self):
     locale = l10n_utils.get_locale(self.request)
     if locale in self.fxos_locales:
         template = 'firefox/whatsnew-fxos.html'
     else:
         template = 'firefox/whatsnew.html'
     return template
Exemplo n.º 23
0
    def get_template_names(self):
        version = self.kwargs.get("version") or ""
        locale = l10n_utils.get_locale(self.request)

        # variant is present for growth tests
        ctx = funnelcake_param(self.request)

        variant = ctx.get("funnelcake_id", None)

        if variant == "35" and version == "35.0.1":
            template = "firefox/australis/growth-firstrun-test1.html"
        elif variant == "36" and version == "35.0.1":
            template = "firefox/australis/growth-firstrun-test2.html"
        elif show_devbrowser_firstrun_or_whatsnew(version):
            if waffle.switch_is_active("dev-edition-spring-campaign"):
                template = "firefox/dev-firstrun-spring-campaign.html"
            else:
                template = "firefox/dev-firstrun.html"
        elif show_38_0_5_firstrun_or_whatsnew(version):
            template = "firefox/australis/fx38_0_5/firstrun.html"
        elif show_36_firstrun(version):
            template = "firefox/australis/fx36/firstrun-tour.html"
        elif show_search_firstrun(version) and locale == "en-US":
            template = "firefox/australis/firstrun-34-tour.html"
        else:
            template = "firefox/australis/firstrun-tour.html"

        # return a list to conform with original intention
        return [template]
Exemplo n.º 24
0
    def get_template_names(self):
        version = self.kwargs.get('fx_version') or ''
        locale = l10n_utils.get_locale(self.request)
        fc_ctx = funnelcake_param(self.request)
        f = fc_ctx.get('funnelcake_id', 0)
        oldversion = self.request.GET.get('oldversion', '')
        # old versions of Firefox sent a prefixed version
        if oldversion.startswith('rv:'):
            oldversion = oldversion[3:]
        versions = ('29.', '30.', '31.', '32.', '33.')

        if version == '29.0a1':
            template = 'firefox/whatsnew-nightly-29.html'
        elif version.startswith(versions):
            if locale == 'en-US' and f == '31':
                # funnelcake build 31 should always get the tour
                template = 'firefox/australis/whatsnew-tour.html'
            elif locale == 'en-US' and f == '30':
                # funnelcake build 30 should not get the tour
                template = 'firefox/australis/whatsnew-no-tour.html'
            elif show_whatsnew_tour(oldversion):
                # updating from pre-29 version
                template = 'firefox/australis/whatsnew-tour.html'
            else:
                # default is no tour
                template = 'firefox/australis/whatsnew-no-tour.html'
        elif locale in self.fxos_locales:
            template = 'firefox/whatsnew-fxos.html'
        else:
            template = 'firefox/whatsnew.html'

        # return a list to conform with original intention
        return [template]
Exemplo n.º 25
0
    def get_template_names(self):
        version = self.kwargs.get('version') or ''

        if show_devbrowser_firstrun_or_whatsnew(version):
            template = 'firefox/dev-firstrun.html'
        elif show_40_firstrun(version):
            v = self.request.GET.get('v', None)
            locale = l10n_utils.get_locale(self.request)

            if (locale == 'en-US' and v in ONBOARDING_VARIATIONS):
                if (v in ['1', '2', '3']):
                    template = 'firefox/onboarding/fxa-simple.html'
                elif (v == '4'):
                    template = 'firefox/onboarding/user-actions-mobileprivacy.html'
                elif (v == '5'):
                    template = 'firefox/onboarding/user-actions-pinsearch.html'
                elif (v == '6'):
                    template = 'firefox/onboarding/fxa-complex.html'
            else:
                template = 'firefox/firstrun/firstrun.html'
        elif show_38_0_5_firstrun_or_whatsnew(version):
            template = 'firefox/australis/fx38_0_5/firstrun.html'
        else:
            template = 'firefox/australis/firstrun.html'

        # return a list to conform with original intention
        return [template]
Exemplo n.º 26
0
def new(request):
    # Remove legacy query parameters (Bug 1236791)
    if request.GET.get('product', None) or request.GET.get('os', None):
        return HttpResponsePermanentRedirect(reverse('firefox.new'))

    locale = l10n_utils.get_locale(request)
    variant = request.GET.get('v', '')
    scene = request.GET.get('scene', None)

    scene_1_variants = ['1a', '2a', '3a', '4a', '1b', '2b', '3b', '4b']
    scene_2_variants = ['a', 'b']

    if scene == '2':
        if locale == 'en-US' and variant in scene_2_variants:
            template = 'firefox/new/variants/scene2/variant-{0}.html'.format(variant)
        else:
            template = 'firefox/new/scene2.html'
    # if no/incorrect scene specified, show scene 1
    else:
        if locale == 'en-US' and variant in scene_1_variants:
            template = 'firefox/new/variants/scene1/variant-{0}.html'.format(variant)
        else:
            template = 'firefox/new/scene1.html'

    return l10n_utils.render(request, template)
Exemplo n.º 27
0
def channel_desktop(request):
    locale = l10n_utils.get_locale(request)
    version = request.GET.get('v', None)

    if (locale != 'en-US' or version != 'b'):
        version = None

    return l10n_utils.render(request, 'firefox/channel/desktop.html', {'version': version})
Exemplo n.º 28
0
def developer(request):
    locale = l10n_utils.get_locale(request)
    version = request.GET.get('v', None)

    if (locale != 'en-US' or version != 'b'):
        version = None

    return l10n_utils.render(request, 'firefox/developer.html', {'version': version})
Exemplo n.º 29
0
def new_home(request, locale=None):
    locale = locale or l10n_utils.get_locale(request)
    return l10n_utils.render(
        request, 'mozorg/home/home-new.html', {
            'has_contribute': lang_file_is_active('mozorg/contribute'),
            'tweets': home_tweets(locale),
            'mobilizer_link': settings.MOBILIZER_LOCALE_LINK.get(
                locale, settings.MOBILIZER_LOCALE_LINK['en-US'])})
Exemplo n.º 30
0
def sync(request):
    locale = l10n_utils.get_locale(request)
    version = request.GET.get('v', None)

    if (locale != 'en-US' or version not in ['2', '3']):
        version = None

    return l10n_utils.render(request, 'firefox/sync.html', {'version': version})
Exemplo n.º 31
0
def firefox_welcome_page1(request):
    locale = l10n_utils.get_locale(request)

    # get localized blog post URL for 2019 page
    breach_tips_query = (
        '?utm_source=mozilla.org-firefox-welcome-1&utm_medium=referral'
        '&utm_campaign=welcome-1-monitor&entrypoint=mozilla.org-firefox-welcome-1'
    )
    breach_tips_url = BREACH_TIPS_URLS.get(locale, BREACH_TIPS_URLS['en-US'])

    context = {'breach_tips_url': breach_tips_url + breach_tips_query}

    template_name = 'firefox/welcome/page1.html'

    return l10n_utils.render(request,
                             template_name,
                             context,
                             ftl_files='firefox/welcome/page1')
Exemplo n.º 32
0
    def get_template_names(self):
        locale = l10n_utils.get_locale(self.request)
        version = self.kwargs.get('version') or ''

        if detect_channel(version) == 'alpha':
            template = 'firefox/dev-firstrun.html'
        elif show_40_firstrun(version):
            if lang_file_is_active('firefox/new/onboarding', locale):
                template = 'firefox/firstrun/onboarding.html'
            else:
                template = 'firefox/firstrun/firstrun-horizon.html'
        elif show_38_0_5_firstrun(version):
            template = 'firefox/australis/fx38_0_5/firstrun.html'
        else:
            template = 'firefox/australis/firstrun.html'

        # return a list to conform with original intention
        return [template]
Exemplo n.º 33
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', 'fr', 'en-US'],
    }

    if locale == 'de':
        template_name = 'firefox/election/index-de.html'
        ctx['page_content_cards'] = get_page_content_cards('election-de', 'de')
    elif locale == 'fr':
        template_name = 'firefox/election/index-fr.html'
        ctx['page_content_cards'] = get_page_content_cards('election-fr', 'fr')
    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)
Exemplo n.º 34
0
def new(request):
    # Remove legacy query parameters (Bug 1236791)
    if request.GET.get('product', None) or request.GET.get('os', None):
        return HttpResponsePermanentRedirect(reverse('firefox.new'))

    scene = request.GET.get('scene', None)
    experience = request.GET.get('xv', None)
    variant = request.GET.get('v', None)
    locale = l10n_utils.get_locale(request)

    # ensure variant matches pre-defined value
    if variant not in []:  # place expected ?v= values in this list
        variant = None

    if scene == '2':
        # send to new permanent scene2 URL (bug 1438302)
        thanks_url = reverse('firefox.download.thanks')
        query_string = request.META.get('QUERY_STRING', '')
        if query_string:
            done_url = '?'.join(
                [thanks_url,
                 force_text(query_string, errors='ignore')])
        return HttpResponsePermanentRedirect(done_url)
    # if no/incorrect scene specified, show scene 1
    else:
        if lang_file_is_active('firefox/new/wait-face',
                               locale) and experience == 'waitface':
            template = 'firefox/new/wait-face/scene1.html'
        elif lang_file_is_active('firefox/new/reggiewatts',
                                 locale) and experience == 'reggiewatts':
            template = 'firefox/new/reggie-watts/scene1.html'
        elif locale == 'de' and experience == 'berlin':
            template = 'firefox/new/berlin/scene1.html'
        elif locale == 'en-US':
            if experience == 'portland':
                template = 'firefox/new/portland/scene1.html'
            else:
                template = 'firefox/new/scene1.html'
        else:
            template = 'firefox/new/scene1.html'

    # no harm done by passing 'v' to template, even when no experiment is running
    # (also makes tests easier to maintain by always sending a context)
    return l10n_utils.render(request, template, {'v': variant})
Exemplo n.º 35
0
def download_thanks(request):
    experience = request.GET.get('xv', None)
    locale = l10n_utils.get_locale(request)
    variant = request.GET.get('v', None)
    newsletter = request.GET.get('n', None)
    show_newsletter = locale in [
        'en-US', 'en-GB', 'en-CA', 'es-ES', 'es-AR', 'es-CL', 'es-MX', 'pt-BR',
        'fr', 'ru', 'id', 'de', 'pl'
    ]

    # ensure variant matches pre-defined value
    if variant not in ['b']:  # place expected ?v= values in this list
        variant = None

    # check to see if a URL explicitly asks to hide the newsletter
    if newsletter == 'f':
        show_newsletter = False

    if locale == 'de':
        if experience == 'berlin':
            template = 'firefox/campaign/berlin/scene2.html'
        elif experience == 'aus-gruenden':
            template = 'firefox/campaign/berlin/scene2-aus-gruenden.html'
        elif experience == 'herz':
            template = 'firefox/campaign/berlin/scene2-herz.html'
        elif experience == 'geschwindigkeit':
            template = 'firefox/campaign/berlin/scene2-gesch.html'
        elif experience == 'privatsphare':
            template = 'firefox/campaign/berlin/scene2-privat.html'
        elif experience == 'auf-deiner-seite':
            template = 'firefox/campaign/berlin/scene2-auf-deiner-seite.html'
        elif lang_file_is_active('firefox/new/trailhead', locale):
            template = 'firefox/new/trailhead/thanks.html'
        else:
            template = 'firefox/new/scene2.html'
    elif locale == 'en-US' and experience == 'betterbrowser':
        template = 'firefox/campaign/better-browser/scene2.html'
    elif lang_file_is_active('firefox/new/trailhead', locale):
        template = 'firefox/new/trailhead/thanks.html'
    else:
        template = 'firefox/new/scene2.html'

    return l10n_utils.render(request, template,
                             {'show_newsletter': show_newsletter})
Exemplo n.º 36
0
    def get_template_names(self):
        locale = l10n_utils.get_locale(self.request)

        version = self.kwargs.get('version') or ''
        oldversion = self.request.GET.get('oldversion', '')
        # old versions of Firefox sent a prefixed version
        if oldversion.startswith('rv:'):
            oldversion = oldversion[3:]

        channel = detect_channel(version)

        if channel == 'nightly':
            template = 'firefox/nightly_whatsnew.html'
        elif channel == 'alpha':
            if version.startswith('68.') and switch('dev_whatsnew_68'):
                template = 'firefox/developer/whatsnew-fx68.html'
            elif show_57_dev_whatsnew(version):
                template = 'firefox/developer/whatsnew.html'
            else:
                template = 'firefox/dev-whatsnew.html'
        elif channel == 'beta':
            if version.startswith('68.'):
                template = 'firefox/whatsnew/beta/whatsnew-fx68.html'
            else:
                template = 'firefox/whatsnew/index.html'
        elif locale == 'id':
            template = 'firefox/whatsnew/index-lite.id.html'
        elif locale == 'zh-TW' and not version.startswith('64.'):
            template = 'firefox/whatsnew/index.zh-TW.html'
        elif version.startswith('67.'):
            template = 'firefox/whatsnew/whatsnew-fx67.html'
        elif version.startswith('66.'):
            template = 'firefox/whatsnew/whatsnew-fx66.html'
        elif version.startswith('65.'):
            template = 'firefox/whatsnew/whatsnew-fx65.html'
        elif version.startswith('64.'):
            template = 'firefox/whatsnew/fx64/whatsnew-fx64.html'
        elif version.startswith('63.'):
            template = 'firefox/whatsnew/whatsnew-fx63.html'
        else:
            template = 'firefox/whatsnew/index.html'

        # return a list to conform with original intention
        return [template]
Exemplo n.º 37
0
    def get_template_names(self):
        locale = l10n_utils.get_locale(self.request)

        version = self.kwargs.get('version') or ''
        oldversion = self.request.GET.get('oldversion', '')
        # old versions of Firefox sent a prefixed version
        if oldversion.startswith('rv:'):
            oldversion = oldversion[3:]

        channel = detect_channel(version)
        if channel == 'alpha':
            if show_57_dev_whatsnew(version):
                template = 'firefox/developer/whatsnew.html'
            else:
                template = 'firefox/dev-whatsnew.html'
        elif channel == 'nightly':
            template = 'firefox/nightly_whatsnew.html'
        elif show_60_whatsnew(version, oldversion):
            if locale == 'id':
                template = 'firefox/whatsnew/index.id.html'
            elif locale == 'zh-TW':
                template = 'firefox/whatsnew/index.zh-TW.html'
            else:
                template = 'firefox/whatsnew/whatsnew-fx60.html'
        elif show_59_whatsnew(version, oldversion):
            if locale == 'id':
                template = 'firefox/whatsnew/index.id.html'
            elif locale == 'zh-TW':
                template = 'firefox/whatsnew/index.zh-TW.html'
            else:
                template = 'firefox/whatsnew/whatsnew-fxa.html'
        elif show_57_whatsnew(version, oldversion):
            # locale-specific templates don't seem to work for the default locale
            if locale == 'en-US':
                template = 'firefox/whatsnew/fx57/whatsnew-57.en-US.html'
            # locale-specific templates for de, en-GB, es-AR, es-CL, es-ES, es-MX,
            # fr, id, pl, pt-BR, ru, zh-CN, and zh-TW
            else:
                template = 'firefox/whatsnew/fx57/whatsnew-57.html'
        else:
            template = 'firefox/whatsnew/index.html'

        # return a list to conform with original intention
        return [template]
Exemplo n.º 38
0
def home(request, template='mozorg/home/home.html'):
    locale = l10n_utils.get_locale(request)

    # en-US gets new template
    # not using locale-specific templates naming scheme yet as page/test results
    # are still in flux
    if locale == 'en-US':
        template = 'mozorg/home/home-en-US.html'

    return l10n_utils.render(
        request, template, {
            'has_contribute':
            lang_file_is_active('mozorg/contribute'),
            'tweets':
            home_tweets(locale),
            'mobilizer_link':
            settings.MOBILIZER_LOCALE_LINK.get(
                locale, settings.MOBILIZER_LOCALE_LINK['en-US'])
        })
Exemplo n.º 39
0
    def get_template_names(self):
        locale = l10n_utils.get_locale(self.request)

        version = self.kwargs.get('version') or ''
        oldversion = self.request.GET.get('oldversion', '')
        # old versions of Firefox sent a prefixed version
        if oldversion.startswith('rv:'):
            oldversion = oldversion[3:]

        channel = detect_channel(version)
        if channel == 'alpha':
            if show_57_dev_whatsnew(version) and lang_file_is_active(
                    'firefox/products/developer-quantum', locale):
                template = 'firefox/developer-quantum-whatsnew.html'
            else:
                template = 'firefox/dev-whatsnew.html'
        elif channel == 'nightly':
            template = 'firefox/nightly_whatsnew.html'
        elif show_57_whatsnew(version):
            # locale-specific templates don't seem to work for the default locale
            if locale == 'en-US':
                template = 'firefox/whatsnew/fx57/whatsnew-57.en-US.html'
            # locale-specific templates for de, en-GB, es-AR, es-CL, es-ES, es-MX,
            # fr, id, pl, pt-BR, ru, zh-CN, and zh-TW
            else:
                template = 'firefox/whatsnew/fx57/whatsnew-57.html'
        elif show_56_whatsnew(version, oldversion):
            template = 'firefox/whatsnew/whatsnew-56.html'
        elif show_54_whatsnew(version):
            template = 'firefox/whatsnew/fx54/whatsnew-54.html'
        elif show_50_whatsnew(version):
            # zh-TW has locale-specific template: whatsnew-50.zh-TW.html
            template = 'firefox/whatsnew/whatsnew-50.html'
        # zh-TW on 49.0 gets a special template
        elif locale == 'zh-TW' and show_49_0_whatsnew(version):
            template = 'firefox/whatsnew/whatsnew-zh-tw-49.html'
        elif show_42_whatsnew(version):
            template = 'firefox/whatsnew/whatsnew-42.html'
        else:
            template = 'firefox/australis/whatsnew.html'

        # return a list to conform with original intention
        return [template]
Exemplo n.º 40
0
    def get_context_data(self, **kwargs):
        ctx = super(WhatsnewView, self).get_context_data(**kwargs)
        locale = l10n_utils.get_locale(self.request)

        # add version to context for use in templates
        version = self.kwargs.get('version') or ''
        match = re.match(r'\d{1,2}', version)
        ctx['version'] = version
        ctx['num_version'] = int(match.group(0)) if match else ''
        if ctx['num_version'] == 64:
            ctx['active_locales'] = [
                'de',
                'en-CA',
                'en-GB',
                'en-US',
                'es-ES',
                'fr',
                'id',
                'pl',
                'pt-BR',
                'ru',
                'zh-TW',
            ]

        if ctx['num_version'] in [65, 66]:
            ctx['show_newsletter'] = locale in [
                'en-US',
                'en-GB',
                'en-CA',
                'en-ZA',
                'es-ES',
                'es-AR',
                'es-CL',
                'es-MX',
                'id',
                'pt-BR',
                'fr',
                'ru',
                'de',
                'pl'
            ]

        return ctx
Exemplo n.º 41
0
    def get_template_names(self):
        locale = l10n_utils.get_locale(self.request)
        variant = self.request.GET.get('v', None)

        # ensure variant matches pre-defined value
        if variant not in self.variations:
            variant = None

        if locale == 'ru' and switch('firefox-yandex'):
            template = 'firefox/new/trailhead/download-yandex.html'
        elif ftl_file_is_active('firefox/new/desktop') and switch(
                'new-redesign'):
            template = 'firefox/new/desktop/download.html'
        elif ftl_file_is_active('firefox/new/download'):
            template = 'firefox/new/trailhead/download.html'
        else:
            template = 'firefox/new/protocol/download.html'

        return [template]
Exemplo n.º 42
0
    def get_context_data(self, **kwargs):
        ctx = super(WhatsnewView, self).get_context_data(**kwargs)
        locale = l10n_utils.get_locale(self.request)

        # add version to context for use in templates
        version = self.kwargs.get('version') or ''
        match = re.match(r'\d{1,2}', version)
        num_version = int(match.group(0)) if match else ''
        ctx['version'] = version
        ctx['num_version'] = num_version

        # add analytics parameters to context for use in templates
        channel = detect_channel(version)
        if channel not in ['nightly', 'developer', 'beta']:
            channel = ''

        analytics_version = str(num_version) + channel
        entrypoint = 'mozilla.org-whatsnew' + analytics_version
        campaign = 'whatsnew' + analytics_version
        ctx['analytics_version'] = analytics_version
        ctx['entrypoint'] = entrypoint
        ctx['campaign'] = campaign
        ctx['utm_params'] = 'utm_source={0}&utm_medium=referral&utm_campaign={1}&entrypoint={2}'.format(
                             entrypoint, campaign, entrypoint)

        if ctx['num_version'] in [67, 68]:
            ctx['show_newsletter'] = locale in [
                'en-US',
                'en-GB',
                'en-CA',
                'es-ES',
                'es-AR',
                'es-CL',
                'es-MX',
                'id',
                'pt-BR',
                'fr',
                'ru',
                'de',
                'pl',
            ]

        return ctx
Exemplo n.º 43
0
    def get_template_names(self):
        locale = l10n_utils.get_locale(self.request)
        version = self.kwargs.get('version') or ''
        oldversion = self.request.GET.get('oldversion', '')
        # old versions of Firefox sent a prefixed version
        if oldversion.startswith('rv:'):
            oldversion = oldversion[3:]

        channel = detect_channel(version)

        if channel == 'nightly':
            template = 'firefox/nightly/whatsnew.html'
        elif channel == 'developer':
            if show_57_dev_whatsnew(version):
                template = 'firefox/developer/whatsnew.html'
            else:
                template = 'firefox/whatsnew/index.html'
        elif version.startswith('84.') and locale.startswith('en-'):
            template = 'firefox/whatsnew/whatsnew-fx84.html'
        elif version.startswith('83.') and locale == ('de'):
            template = 'firefox/whatsnew/whatsnew-fx83-de.html'
        elif version.startswith('83.') and locale.startswith('en-'):
            template = 'firefox/whatsnew/whatsnew-fx83-en.html'
        elif version.startswith('82.') and locale.startswith('en-'):
            template = 'firefox/whatsnew/whatsnew-fx82.html'
        elif version.startswith('81.') and ftl_file_is_active(
                'firefox/whatsnew/whatsnew-fx81'):
            template = 'firefox/whatsnew/whatsnew-fx81.html'
        elif version.startswith('80.') and ftl_file_is_active(
                'firefox/whatsnew/whatsnew-fx80'):
            template = 'firefox/whatsnew/whatsnew-fx80.html'
        elif version.startswith('79.') and ftl_file_is_active(
                'firefox/whatsnew/whatsnew-fx79'):
            template = 'firefox/whatsnew/whatsnew-fx79.html'
        else:
            if show_default_account_whatsnew(version) and ftl_file_is_active(
                    'firefox/whatsnew/whatsnew-account'):
                template = 'firefox/whatsnew/index-account.html'
            else:
                template = 'firefox/whatsnew/index.html'

        # return a list to conform with original intention
        return [template]
Exemplo n.º 44
0
    def get_context_data(self, **kwargs):
        ctx = super().get_context_data(**kwargs)
        version = self.kwargs.get("version") or ""
        pre_release_channels = ["nightly", "developer", "beta"]
        channel = detect_channel(version)

        # add active_locales for hard-coded locale templates
        locale = l10n_utils.get_locale(self.request)
        hard_coded_templates = ["id"]
        if locale in hard_coded_templates and channel not in pre_release_channels:
            ctx["active_locales"] = locale

        # add version to context for use in templates
        match = re.match(r"\d{1,3}", version)
        num_version = int(match.group(0)) if match else ""
        ctx["version"] = version
        ctx["num_version"] = num_version

        # add analytics parameters to context for use in templates
        if channel not in pre_release_channels:
            channel = ""

        # add VPN waitlist form for WNP 87/88 (Issue 9956, 10049)
        if version.startswith("87.") or version.startswith("88.") and locale in ["de", "fr"]:
            ctx["newsletter_form"] = VPNWaitlistForm(locale)

        analytics_version = str(num_version) + channel
        entrypoint = "mozilla.org-whatsnew" + analytics_version
        campaign = "whatsnew" + analytics_version
        ctx["analytics_version"] = analytics_version
        ctx["entrypoint"] = entrypoint
        ctx["campaign"] = campaign
        ctx["utm_params"] = f"utm_source={entrypoint}&utm_medium=referral&utm_campaign={campaign}&entrypoint={entrypoint}"

        variant = self.request.GET.get("v", None)

        # ensure variant matches pre-defined value
        if variant not in self.variations:
            variant = None

        ctx["variant"] = variant

        return ctx
Exemplo n.º 45
0
    def get_template_names(self):
        locale = l10n_utils.get_locale(self.request)
        version = self.kwargs.get('version') or ''
        exp = self.request.GET.get('v')

        if detect_channel(version) == 'alpha':
            template = 'firefox/dev-firstrun.html'
        elif show_40_firstrun(version):
            if locale == 'en-US' and exp in ['a', 'b']:
                template = 'firefox/firstrun/index-{0}.html'.format(exp)
            else:
                template = 'firefox/firstrun/index.html'
        elif show_38_0_5_firstrun(version):
            template = 'firefox/australis/fx38_0_5/firstrun.html'
        else:
            template = 'firefox/australis/firstrun.html'

        # return a list to conform with original intention
        return [template]
Exemplo n.º 46
0
def campaign(request):

    # note: v and xv params only allow a-z, A-Z, 0-9, -, and _ charcaters
    experience = request.GET.get('xv', None)
    variant = request.GET.get('v', None)

    locale = l10n_utils.get_locale(request)

    # ensure variant matches pre-defined value

    if variant not in []:  # place expected ?v= values in this list
        variant = None

    if locale == 'de':
        if experience == 'berlin':
            template = 'firefox/campaign/berlin/scene1.html'
        elif experience == 'aus-gruenden':
            template = 'firefox/campaign/berlin/scene1-aus-gruenden.html'
        elif experience == 'herz':
            template = 'firefox/campaign/berlin/scene1-herz.html'
        elif experience == 'geschwindigkeit':
            template = 'firefox/campaign/berlin/scene1-gesch.html'
        elif experience == 'privatsphare':
            template = 'firefox/campaign/berlin/scene1-privat.html'
        elif experience == 'auf-deiner-seite':
            template = 'firefox/campaign/berlin/scene1-auf-deiner-seite.html'
        else:
            template = 'firefox/campaign/index.html'
    elif locale == 'en-US':
        if experience == 'betterbrowser':
            template = 'firefox/campaign/better-browser/scene1.html'
        elif experience == 'safari':
            template = 'firefox/campaign/compare/scene1-safari.html'
        elif experience == 'edge':
            template = 'firefox/campaign/compare/scene1-edge.html'
        else:
            template = 'firefox/campaign/index.html'
    else:
        template = 'firefox/campaign/index.html'

    # no harm done by passing 'v' to template, even when no experiment is running
    # (also makes tests easier to maintain by always sending a context)
    return l10n_utils.render(request, template, {'experience': experience, 'v': variant})
Exemplo n.º 47
0
    def get_template_names(self):
        version = self.kwargs.get('version') or ''
        locale = l10n_utils.get_locale(self.request)

        if show_devbrowser_firstrun_or_whatsnew(version):
            template = 'firefox/dev-firstrun.html'
        elif show_40_firstrun(version):
            template = 'firefox/australis/fx40/firstrun.html'
        elif show_38_0_5_firstrun_or_whatsnew(version):
            template = 'firefox/australis/fx38_0_5/firstrun.html'
        elif show_36_firstrun(version):
            template = 'firefox/australis/fx36/firstrun-tour.html'
        elif show_search_firstrun(version) and locale == 'en-US':
            template = 'firefox/australis/firstrun-34-tour.html'
        else:
            template = 'firefox/australis/firstrun-tour.html'

        # return a list to conform with original intention
        return [template]
Exemplo n.º 48
0
def download_thanks(request):
    experience = request.GET.get('xv', None)
    locale = l10n_utils.get_locale(request)
    variant = request.GET.get('v', None)
    show_newsletter = locale in [
        'en-US', 'en-GB', 'en-CA', 'en-ZA', 'es-ES', 'es-AR', 'es-CL', 'es-MX',
        'pt-BR', 'fr', 'ru', 'id', 'de', 'pl'
    ]
    pre_download_locales = ['en-US', 'en-GB', 'en-CA', 'en-ZA', 'de', 'fr']

    # ensure variant matches pre-defined value
    if variant not in ['a']:  # place expected ?v= values in this list
        variant = None

    if variant == 'a' and locale in pre_download_locales:
        show_newsletter = False  # Prevent showing the newsletter for pre-download experiment Issue #6456

    if locale == 'de':
        if experience == 'berlin':
            template = 'firefox/new/berlin/scene2.html'
        elif experience == 'aus-gruenden':
            template = 'firefox/new/berlin/scene2-aus-gruenden.html'
        elif experience == 'herz':
            template = 'firefox/new/berlin/scene2-herz.html'
        elif experience == 'geschwindigkeit':
            template = 'firefox/new/berlin/scene2-gesch.html'
        elif experience == 'privatsphare':
            template = 'firefox/new/berlin/scene2-privat.html'
        elif experience == 'auf-deiner-seite':
            template = 'firefox/new/berlin/scene2-auf-deiner-seite.html'
        else:
            template = 'firefox/new/scene2.html'
    elif locale == 'en-US':
        if experience == 'betterbrowser':
            template = 'firefox/new/better-browser/scene2.html'
        else:
            template = 'firefox/new/scene2.html'
    else:
        template = 'firefox/new/scene2.html'

    return l10n_utils.render(request, template,
                             {'show_newsletter': show_newsletter})
Exemplo n.º 49
0
def new(request):
    # Remove legacy query parameters (Bug 1236791)
    if request.GET.get('product', None) or request.GET.get('os', None):
        return HttpResponsePermanentRedirect(reverse('firefox.new'))

    scene = request.GET.get('scene', None)

    # note: v and xv params only allow a-z, A-Z, 0-9, -, and _ characters
    experience = request.GET.get('xv', None)
    variant = request.GET.get('v', None)

    locale = l10n_utils.get_locale(request)

    # ensure variant matches pre-defined value

    if variant not in ['a', 'b']:  # place expected ?v= values in this list
        variant = None

    if scene == '2':
        # send to new permanent scene2 URL (bug 1438302)
        thanks_url = reverse('firefox.download.thanks')
        query_string = request.META.get('QUERY_STRING', '')
        if query_string:
            thanks_url = '?'.join(
                [thanks_url,
                 force_text(query_string, errors='ignore')])
        return HttpResponsePermanentRedirect(thanks_url)
    # if no/incorrect scene specified, show scene 1
    else:
        if locale == 'ru' and switch('firefox-yandex'):
            template = 'firefox/new/yandex/scene1.html'
        elif lang_file_is_active('firefox/new/trailhead', locale):
            template = 'firefox/new/trailhead/download.html'
        else:
            template = 'firefox/new/scene1.html'

    # no harm done by passing 'v' to template, even when no experiment is running
    # (also makes tests easier to maintain by always sending a context)
    return l10n_utils.render(request, template, {
        'experience': experience,
        'v': variant
    })
Exemplo n.º 50
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', 'en-US')
    else:
        template_name = 'mozorg/home/home.html'

    return l10n_utils.render(request, template_name, ctx)
Exemplo n.º 51
0
def home(request, template='mozorg/home/home.html'):
    locale = l10n_utils.get_locale(request)

    if lang_file_is_active('mozorg/home/index-2016', locale):
        # check for variant - fx copy experiment
        v = request.GET.get('v', None)

        if (locale.startswith('en-') and v in ['a', 'b', 'c']):
            template = 'mozorg/home/home-{0}.html'.format(v)
        else:
            template = 'mozorg/home/home.html'
    else:
        template = 'mozorg/home/home-voices.html'

    return l10n_utils.render(
        request, template, {
            'has_contribute': lang_file_is_active('mozorg/contribute'),
            'tweets': home_tweets(locale),
            'mobilizer_link': settings.MOBILIZER_LOCALE_LINK.get(
                locale, settings.MOBILIZER_LOCALE_LINK['en-US'])})
Exemplo n.º 52
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-2020', '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)
Exemplo n.º 53
0
def new(request):
    # Remove legacy query parameters (Bug 1236791)
    if request.GET.get('product', None) or request.GET.get('os', None):
        return HttpResponsePermanentRedirect(reverse('firefox.new'))

    scene = request.GET.get('scene', None)

    if scene == '2':
        template = 'firefox/new/scene2.html'
    # if no/incorrect scene specified, show scene 1
    else:
        template = 'firefox/new/scene1.html'

        # en-US tests
        locale = l10n_utils.get_locale(request)

        if locale == 'en-US' and request.GET.get('v', None) == '1':
            template = 'firefox/new/scene1-ie8.html'

    return l10n_utils.render(request, template)
Exemplo n.º 54
0
def about_view(request):
    locale = l10n_utils.get_locale(request)
    variant = request.GET.get('v', None)
    allowed_variants = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']

    # ensure variant matches pre-defined value
    if variant not in allowed_variants:
        variant = None

    if lang_file_is_active('mozorg/about-2019', locale):
        if variant == 'a':
            template_name = 'mozorg/perf-exp/control.html'
        elif variant in allowed_variants:
            template_name = 'mozorg/perf-exp/variation.html'
        else:
            template_name = 'mozorg/about-2019.html'
    else:
        template_name = 'mozorg/about.html'

    return l10n_utils.render(request, template_name, {'variant': variant})
Exemplo n.º 55
0
    def get_template_names(self):
        funnelcake = self.request.GET.get('f', '')
        locale = l10n_utils.get_locale(self.request)
        version = self.kwargs.get('version') or ''

        if detect_channel(version) == 'alpha':
            template = 'firefox/dev-firstrun.html'
        elif show_40_firstrun(version):
            if locale == 'en-US' and funnelcake == '90':
                # ravioli/katie couric promo
                template = 'firefox/firstrun/ravioli.html'
            else:
                template = 'firefox/firstrun/firstrun-horizon.html'
        elif show_38_0_5_firstrun(version):
            template = 'firefox/australis/fx38_0_5/firstrun.html'
        else:
            template = 'firefox/australis/firstrun.html'

        # return a list to conform with original intention
        return [template]
Exemplo n.º 56
0
def download_thanks(request):
    experience = request.GET.get('xv', None)
    locale = l10n_utils.get_locale(request)

    # `wait-face`, `reggiewatts` variations are currently localized for both en-US and de locales.
    if lang_file_is_active('firefox/new/wait-face',
                           locale) and experience == 'waitface':
        template = 'firefox/new/wait-face/scene2.html'
    elif lang_file_is_active('firefox/new/reggiewatts',
                             locale) and experience == 'reggiewatts':
        template = 'firefox/new/reggie-watts/scene2.html'
    elif locale == 'en-US':
        if experience == 'portland':
            template = 'firefox/new/portland/scene2.html'
        else:
            template = 'firefox/new/scene2.html'
    else:
        template = 'firefox/new/scene2.html'

    return l10n_utils.render(request, template)
Exemplo n.º 57
0
    def get_template_names(self):
        version = self.kwargs.get('version') or ''
        experience = self.request.GET.get('xv', None)
        locale = l10n_utils.get_locale(self.request)

        if detect_channel(version) == 'alpha':
            if show_57_dev_firstrun(version):
                template = 'firefox/developer/firstrun.html'
            else:
                template = 'firefox/dev-firstrun.html'
        elif show_62_firstrun(version):
            if locale == 'en-US' and experience == 'firefox-election':
                template = 'firefox/firstrun/firstrun-election.html'
            else:
                template = 'firefox/firstrun/firstrun-quantum.html'
        else:
            template = 'firefox/firstrun/firstrun-quantum.html'

        # return a list to conform with original intention
        return [template]
Exemplo n.º 58
0
    def get_context_data(self, **kwargs):
        ctx = super(WhatsnewView, self).get_context_data(**kwargs)
        version = self.kwargs.get('version') or ''
        pre_release_channels = ['nightly', 'developer', 'beta']
        channel = detect_channel(version)

        # add active_locales for hard-coded locale templates
        locale = l10n_utils.get_locale(self.request)
        hard_coded_templates = ['id']
        if locale in hard_coded_templates and channel not in pre_release_channels:
            ctx['active_locales'] = locale

        # add version to context for use in templates
        match = re.match(r'\d{1,2}', version)
        num_version = int(match.group(0)) if match else ''
        ctx['version'] = version
        ctx['num_version'] = num_version

        # add analytics parameters to context for use in templates
        if channel not in pre_release_channels:
            channel = ''

        # add VPN waitlist form for WNP 87 (Issue 9956)
        if version.startswith('87.') and locale in ['de', 'fr']:
            ctx['newsletter_form'] = VPNWaitlistForm(locale)

        analytics_version = str(num_version) + channel
        entrypoint = 'mozilla.org-whatsnew' + analytics_version
        if version.startswith('79.') and channel not in [
                'nightly', 'developer', 'beta'
        ]:
            campaign = 'mozilla-vpn-v1-0-announcement'
        else:
            campaign = 'whatsnew' + analytics_version
        ctx['analytics_version'] = analytics_version
        ctx['entrypoint'] = entrypoint
        ctx['campaign'] = campaign
        ctx['utm_params'] = 'utm_source={0}&utm_medium=referral&utm_campaign={1}&entrypoint={2}'.format(
            entrypoint, campaign, entrypoint)

        return ctx
Exemplo n.º 59
0
    def get_template_names(self):
        version = self.kwargs.get('version') or ''

        if show_devbrowser_firstrun_or_whatsnew(version):
            template = 'firefox/dev-firstrun.html'
        elif show_40_firstrun(version):
            v = self.request.GET.get('v', None)
            locale = l10n_utils.get_locale(self.request)

            if (v == '1' and locale == 'en-US'):
                # space themed variant
                template = 'firefox/onboarding/firstrun-fxa.html'
            else:
                template = 'firefox/firstrun/firstrun.html'
        elif show_38_0_5_firstrun_or_whatsnew(version):
            template = 'firefox/australis/fx38_0_5/firstrun.html'
        else:
            template = 'firefox/australis/firstrun.html'

        # return a list to conform with original intention
        return [template]
Exemplo n.º 60
0
def installer_help(request):
    locale = l10n_utils.get_locale(request)
    installer_lang = request.GET.get('installer_lang', None)
    installer_channel = request.GET.get('channel', None)
    context = {'installer_lang': None, 'installer_channel': None}

    if installer_lang and installer_lang in firefox_desktop.languages:
        context['installer_lang'] = installer_lang

    if installer_channel and installer_channel in INSTALLER_CHANNElS:
        if installer_channel == 'aurora':
            context['installer_channel'] = 'alpha'
        else:
            context['installer_channel'] = installer_channel

    if lang_file_is_active('firefox/installer-help-redesign', locale):
        template = 'firefox/installer-help-redesign.html'
    else:
        template = 'firefox/installer-help.html'

    return l10n_utils.render(request, template, context)