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)
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 update page. - Non Firefox users go to the new page. """ user_agent = request.META.get('HTTP_USER_AGENT', '') if not 'Firefox' in user_agent: url = reverse('firefox.new') # TODO : Where to redirect bug 757206 return HttpResponsePermanentRedirect(url) 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) 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})
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-4 version if (view == 'b' and (int(version) < 1 or int(version) > 4)): 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)