Skip to content

Instantly share code, notes, and snippets.

@agscala
Created October 8, 2010 19:39
Show Gist options
  • Save agscala/617395 to your computer and use it in GitHub Desktop.
Save agscala/617395 to your computer and use it in GitHub Desktop.
from django.http import HttpResponseRedirect
def has_perm_or_redirect(permission, redirect):
def wrapper(function):
def wrapped_function(request, *args, **kwargs):
if request.user.has_perm("tpd4.NONE"):
print request.user.has_perm("blah")
return function(request, *args, **kwargs)
else:
return HttpResponseRedirect(redirect)
return wrapped_function
return wrapper
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment