Skip to content

Instantly share code, notes, and snippets.

@pmclanahan
Created October 22, 2015 17:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pmclanahan/fdd3635aa0b5cde96cfe to your computer and use it in GitHub Desktop.
Save pmclanahan/fdd3635aa0b5cde96cfe to your computer and use it in GitHub Desktop.
A view that redirects based on waffle, keeping query params.
from django.http import HttpResponseRedirect
from django.utils.encoding import force_text
import waffle
from bedrock.base.urlresolvers import reverse
from lib.l10n_utils import render
def choose_view(request):
if waffle.switch_is_active('tracking-protection'):
return render(request, 'firefox/tracking-protection.html')
else:
query = force_text(request.META.get('QUERY_STRING'), errors='ignore')
return HttpResponseRedirect('?'.join([reverse('firefox.new'), query]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment