Created
February 6, 2012 02:34
-
-
Save ajamaica/1749051 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
from functools import wraps | |
from django.http import HttpResponseRedirect, HttpResponse | |
from django.contrib.auth.models import Group | |
from django.http import Http404 | |
# ya despues solo importalo y usa @decorador arriba de tu función asi evitarar repetir código | |
def decorador(f): | |
def wrap(request, *args, **kwargs): | |
#Aqui la magia de negocio | |
profile = request.user.get_profile() | |
if not profile.decorador: | |
return HttpResponseRedirect('/ruta/') | |
return f(request, *args, **kwargs) | |
wrap.__doc__=f.__doc__ | |
wrap.__name__=f.__name__ | |
return wrap |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment