Skip to content

Instantly share code, notes, and snippets.

@sneeu
Created May 22, 2012 12:15
Show Gist options
  • Save sneeu/2768694 to your computer and use it in GitHub Desktop.
Save sneeu/2768694 to your computer and use it in GitHub Desktop.
def beta_access(request):
if request.method == 'POST':
form = BetaCodeForm(request.POST)
# form validation handles checking for the beta code
if form.is_valid():
request.session['has_beta_access'] = True
return redirect('register')
else:
form = BetaCodeForm(request.POST)
return TemplateResponse(request, 'beta_access.html', context={'form': form})
def beta_access_required(view):
def f(request, *args, **kwargs):
if request.session.get('has_beta_access', None) != True:
return redirect('beta_access')
return view(request, *args, **kwargs)
return f
@pyrat
Copy link

pyrat commented May 24, 2012

Nice, thanks for the rundown. Hopefully I will find an excuse to write some Python in the near future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment