Created
May 22, 2012 12:15
-
-
Save sneeu/2768694 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nice, thanks for the rundown. Hopefully I will find an excuse to write some Python in the near future.