Ejemplo n.º 1
0
    def redirect_to(self):
        """
        Redirect visitors based on their user-agent.

        - Up-to-date Firefox users pass through.
        - Other Firefox users go to the new page.
        - Non Firefox users go to the new page.
        """
        query = self.request.META.get('QUERY_STRING')
        query = '?' + query if query else ''

        user_agent = self.request.META.get('HTTP_USER_AGENT', '')
        if 'Firefox' not in user_agent:
            return reverse('firefox.new') + query
            # TODO : Where to redirect bug 757206

        user_version = '0'
        match = UA_REGEXP.search(user_agent)
        if match:
            user_version = match.group(1)

        if not is_current_or_newer(user_version):
            return reverse('firefox.new') + query

        return None
Ejemplo n.º 2
0
    def redirect_to(self):
        """
        Redirect visitors based on their user-agent.

        - Up-to-date Firefox users pass through.
        - Other Firefox users go to the new page.
        - Non Firefox users go to the new page.
        """
        query = self.request.META.get('QUERY_STRING')
        query = '?' + query if query else ''

        user_agent = self.request.META.get('HTTP_USER_AGENT', '')
        if 'Firefox' not in user_agent:
            return reverse('firefox.new') + query
            # TODO : Where to redirect bug 757206

        user_version = '0'
        match = UA_REGEXP.search(user_agent)
        if match:
            user_version = match.group(1)

        if not is_current_or_newer(user_version):
            return reverse('firefox.new') + query

        return None
Ejemplo n.º 3
0
def firefox_redirect(request):
    """
    Redirect visitors based on their user-agent.

    - Up-to-date Firefox users go to firefox/fx/.
    - Other Firefox users go to the firefox/new/.
    - Non Firefox users go to the new page.
    """
    query = request.META.get('QUERY_STRING')
    query = '?' + query if query else ''

    user_agent = request.META.get('HTTP_USER_AGENT', '')
    if not 'Firefox' in user_agent:
        # TODO : Where to redirect bug 757206
        return HttpResponsePermanentRedirect(reverse('firefox.new') + query)

    user_version = '0'
    match = UA_REGEXP.search(user_agent)
    if match:
        user_version = match.group(1)

    if not is_current_or_newer(user_version):
        return HttpResponsePermanentRedirect(reverse('firefox.new') + query)

    return HttpResponseRedirect(reverse('firefox.fx') + query)
Ejemplo n.º 4
0
    def redirect_to(self):
        """
        Redirect visitors based on their user-agent.

        - Up-to-date Firefox users pass through.
        - Other Firefox users go to the new page.
        - Non Firefox users go to the new page.
        """
        query = self.request.META.get("QUERY_STRING")
        query = "?" + query if query else ""

        user_agent = self.request.META.get("HTTP_USER_AGENT", "")
        if not "Firefox" in user_agent:
            return reverse("firefox.new") + query
            # TODO : Where to redirect bug 757206

        user_version = "0"
        match = UA_REGEXP.search(user_agent)
        if match:
            user_version = match.group(1)

        if not is_current_or_newer(user_version):
            return reverse("firefox.new") + query

        return None
Ejemplo n.º 5
0
def firefox_redirect(request):
    """
    Redirect visitors based on their user-agent.

    - Up-to-date Firefox users go to firefox/fx/.
    - Other Firefox users go to the firefox/new/.
    - Non Firefox users go to the new page.
    """
    query = request.META.get('QUERY_STRING')
    query = '?' + query if query else ''

    user_agent = request.META.get('HTTP_USER_AGENT', '')
    if not 'Firefox' in user_agent:
        # TODO : Where to redirect bug 757206
        return HttpResponsePermanentRedirect(reverse('firefox.new') + query)

    user_version = '0'
    match = UA_REGEXP.search(user_agent)
    if match:
        user_version = match.group(1)

    if not is_current_or_newer(user_version):
        return HttpResponsePermanentRedirect(reverse('firefox.new') + query)

    return HttpResponseRedirect(reverse('firefox.fx') + query)
Ejemplo n.º 6
0
def latest_fx_redirect(request, fake_version, template_name):
    """
    Redirect visitors based on their user-agent.

    - Up-to-date Firefox users see the whatsnew page.
    - Other Firefox users go to the new page.
    - Non Firefox users go to the new page.
    """
    query = request.META.get('QUERY_STRING')
    query = '?' + query if query else ''

    user_agent = request.META.get('HTTP_USER_AGENT', '')
    if not 'Firefox' in user_agent:
        url = reverse('firefox.new') + query
        # TODO : Where to redirect bug 757206
        return HttpResponsePermanentRedirect(url)

    user_version = '0'
    match = UA_REGEXP.search(user_agent)
    if match:
        user_version = match.group(1)

    if not is_current_or_newer(user_version):
        url = reverse('firefox.new') + query
        return HttpResponsePermanentRedirect(url)

    # display alternate firstrun content for en-US with proper funnelcake param in URL
    # remove when firstrun test is complete
    context = funnelcake_param(request)

    if (template_name == 'firefox/firstrun.html' and request.locale == 'en-US'
            and context.get('funnelcake_id',
                            0) == FX_FIRSTRUN_FUNNELCAKE_CAMPAIGN):

        return l10n_utils.render(request, 'firefox/firstrun/a.html')
    else:
        locales_with_video = {
            'en-US': 'american',
            'en-GB': 'british',
            'de': 'german_final',
            'it': 'italian_final',
            'ja': 'japanese_final',
            'es-AR': 'spanish_final',
            'es-CL': 'spanish_final',
            'es-ES': 'spanish_final',
            'es-MX': 'spanish_final',
        }

        return l10n_utils.render(request, template_name,
                                 {'locales_with_video': locales_with_video})
Ejemplo n.º 7
0
def latest_fx_redirect(request, fake_version, template_name):
    """
    Redirect visitors based on their user-agent.

    - Up-to-date Firefox users see the whatsnew page.
    - Other Firefox users go to the new page.
    - Non Firefox users go to the new page.
    """
    query = request.META.get('QUERY_STRING')
    query = '?' + query if query else ''

    user_agent = request.META.get('HTTP_USER_AGENT', '')
    if not 'Firefox' in user_agent:
        url = reverse('firefox.new') + query
        # TODO : Where to redirect bug 757206
        return HttpResponsePermanentRedirect(url)

    user_version = '0'
    match = UA_REGEXP.search(user_agent)
    if match:
        user_version = match.group(1)

    if not is_current_or_newer(user_version):
        url = reverse('firefox.new') + query
        return HttpResponsePermanentRedirect(url)

    # display alternate firstrun content for en-US with proper funnelcake param in URL
    # remove when firstrun test is complete
    context = funnelcake_param(request)

    if (template_name == 'firefox/firstrun.html'
            and request.locale == 'en-US' and
            context.get('funnelcake_id', 0) == FX_FIRSTRUN_FUNNELCAKE_CAMPAIGN):

        return l10n_utils.render(request, 'firefox/firstrun/a.html')
    else:
        locales_with_video = {
            'en-US': 'american',
            'en-GB': 'british',
            'de': 'german_final',
            'it': 'italian_final',
            'ja': 'japanese_final',
            'es-AR': 'spanish_final',
            'es-CL': 'spanish_final',
            'es-ES': 'spanish_final',
            'es-MX': 'spanish_final',
        }

        return l10n_utils.render(request, template_name,
                                 {'locales_with_video': locales_with_video})
Ejemplo n.º 8
0
def plugincheck(request, template='mozorg/plugincheck.html'):
    """
    Determine whether the current UA is the latest Firefox,
    passes the result to the template and renders the
    specified template.
    """
    user_agent = request.META.get('HTTP_USER_AGENT', '')
    user_version = "0"
    ua_regexp = r"Firefox/(%s)" % version_re
    match = re.search(ua_regexp, user_agent)
    if match:
        user_version = match.group(1)

    data = {'is_latest': is_current_or_newer(user_version)}

    return l10n_utils.render(request, template, data)
Ejemplo n.º 9
0
def plugincheck(request, template="mozorg/plugincheck.html"):
    """
    Determine whether the current UA is the latest Firefox,
    passes the result to the template and renders the
    specified template.
    """
    user_agent = request.META.get("HTTP_USER_AGENT", "")
    user_version = "0"
    ua_regexp = r"Firefox/(%s)" % version_re
    match = re.search(ua_regexp, user_agent)
    if match:
        user_version = match.group(1)

    data = {"is_latest": is_current_or_newer(user_version)}

    return l10n_utils.render(request, template, data)
Ejemplo n.º 10
0
def firstrun_new(request, view):
    # only Firefox users should see the firstrun pages
    user_agent = request.META.get('HTTP_USER_AGENT', '')
    if not 'Firefox' in user_agent:
        url = reverse('firefox.new')
        return HttpResponsePermanentRedirect(url)

    # only users on the latest version should see the
    # new pages (for GA experiment data purity)
    user_version = "0"
    ua_regexp = r"Firefox/(%s)" % version_re
    match = re.search(ua_regexp, user_agent)
    if match:
        user_version = match.group(1)

    if not is_current_or_newer(user_version):
        url = reverse('firefox.update')
        return HttpResponsePermanentRedirect(url)

    template = view + '.html'

    return l10n_utils.render(request, 'firefox/firstrun/' + template)
Ejemplo n.º 11
0
def latest_fx_redirect(request, fake_version, template_name):
    """
    Redirect visitors based on their user-agent.

    - Up-to-date Firefox users see the whatsnew page.
    - Other Firefox users go to the new page.
    - Non Firefox users go to the new page.
    """
    query = request.META.get('QUERY_STRING')
    query = '?' + query if query else ''

    user_agent = request.META.get('HTTP_USER_AGENT', '')
    if not 'Firefox' in user_agent:
        url = reverse('firefox.new') + query
        # TODO : Where to redirect bug 757206
        return HttpResponsePermanentRedirect(url)

    user_version = '0'
    match = UA_REGEXP.search(user_agent)
    if match:
        user_version = match.group(1)

    if not is_current_or_newer(user_version):
        url = reverse('firefox.new') + query
        return HttpResponsePermanentRedirect(url)

    locales_with_video = {
        'en-US': 'american',
        'en-GB': 'british',
        'de': 'german_final',
        'it': 'italian_final',
        'ja': 'japanese_final',
        'es-AR': 'spanish_final',
        'es-CL': 'spanish_final',
        'es-ES': 'spanish_final',
        'es-MX': 'spanish_final',
    }
    return l10n_utils.render(request, template_name,
                             {'locales_with_video': locales_with_video})
Ejemplo n.º 12
0
def firstrun_new(request, view):
    # only Firefox users should see the firstrun pages
    user_agent = request.META.get('HTTP_USER_AGENT', '')
    if not 'Firefox' in user_agent:
        url = reverse('firefox.new')
        return HttpResponsePermanentRedirect(url)

    # only users on the latest version should see the
    # new pages (for GA experiment data purity)
    user_version = "0"
    ua_regexp = r"Firefox/(%s)" % version_re
    match = re.search(ua_regexp, user_agent)
    if match:
        user_version = match.group(1)

    if not is_current_or_newer(user_version):
        url = reverse('firefox.update')
        return HttpResponsePermanentRedirect(url)

    template = view + '.html'

    return l10n_utils.render(request, 'firefox/firstrun/' + template)
Ejemplo n.º 13
0
def latest_fx_redirect(request, fake_version, template_name):
    """
    Redirect visitors based on their user-agent.

    - Up-to-date Firefox users see the whatsnew page.
    - Other Firefox users go to the new page.
    - Non Firefox users go to the new page.
    """
    query = request.META.get('QUERY_STRING')
    query = '?' + query if query else ''

    user_agent = request.META.get('HTTP_USER_AGENT', '')
    if not 'Firefox' in user_agent:
        url = reverse('firefox.new') + query
        # TODO : Where to redirect bug 757206
        return HttpResponsePermanentRedirect(url)

    user_version = '0'
    match = UA_REGEXP.search(user_agent)
    if match:
        user_version = match.group(1)

    if not is_current_or_newer(user_version):
        url = reverse('firefox.new') + query
        return HttpResponsePermanentRedirect(url)

    locales_with_video = {
        'en-US': 'american',
        'en-GB': 'british',
        'de': 'german_final',
        'it': 'italian_final',
        'ja': 'japanese_final',
        'es-AR': 'spanish_final',
        'es-CL': 'spanish_final',
        'es-ES': 'spanish_final',
        'es-MX': 'spanish_final',
    }
    return l10n_utils.render(request, template_name,
                             {'locales_with_video': locales_with_video})
Ejemplo n.º 14
0
def firstrun_new(request, view, version):
    # only Firefox users should see the firstrun pages
    user_agent = request.META.get('HTTP_USER_AGENT', '')
    if not 'Firefox' in user_agent:
        url = reverse('firefox.new')
        return HttpResponsePermanentRedirect(url)

    # only users on the latest version should see the
    # new pages (for GA experiment data purity)
    user_version = "0"
    ua_regexp = r"Firefox/(%s)" % version_re
    match = re.search(ua_regexp, user_agent)
    if match:
        user_version = match.group(1)

    if not is_current_or_newer(user_version):
        url = reverse('firefox.update')
        return HttpResponsePermanentRedirect(url)

    # b only has 1-5 version
    if (view == 'b' and (int(version) < 1 or int(version) > 5)):
        version = '1'

    if (view == 'a'):
        copy = 'a' if (version in '123') else 'b'
    else:
        copy = 'a' if (version in '12') else 'b'

    template_vars = {
        'version': version,
        'copy': copy,
    }

    template = view + '.html'

    return l10n_utils.render(request, 'firefox/firstrun/' + template,
                             template_vars)
Ejemplo n.º 15
0
def firstrun_new(request, view, version):
    # only Firefox users should see the firstrun pages
    user_agent = request.META.get('HTTP_USER_AGENT', '')
    if not 'Firefox' in user_agent:
        url = reverse('firefox.new')
        return HttpResponsePermanentRedirect(url)

    # only users on the latest version should see the
    # new pages (for GA experiment data purity)
    user_version = "0"
    ua_regexp = r"Firefox/(%s)" % version_re
    match = re.search(ua_regexp, user_agent)
    if match:
        user_version = match.group(1)

    if not is_current_or_newer(user_version):
        url = reverse('firefox.update')
        return HttpResponsePermanentRedirect(url)

    # b only has 1-5 version
    if (view == 'b' and (int(version) < 1 or int(version) > 5)):
        version = '1'

    if (view == 'a'):
        copy = 'a' if (version in '123') else 'b'
    else:
        copy = 'a' if (version in '12') else 'b'

    template_vars = {
        'version': version,
        'copy': copy,
    }

    template = view + '.html'

    return l10n_utils.render(request, 'firefox/firstrun/' + template, template_vars)