Skip to content

Instantly share code, notes, and snippets.

@walison17
Last active June 3, 2020 17:24
Show Gist options
  • Save walison17/6094c6fccfe9d97e8705f10166bc1496 to your computer and use it in GitHub Desktop.
Save walison17/6094c6fccfe9d97e8705f10166bc1496 to your computer and use it in GitHub Desktop.
from functools import wraps
from django.shortcuts import redirect
def verificar_funcionario(redirect_to='set_password'):
def decorator(view_func):
@wraps(view_func)
def _wrapped_view(request, *args, **kwargs):
if request.user.funcionario.mudou_senha_padrao:
return view_func(request, *args, **kwargs)
return redirect(redirect_to)
return _wrapped_view
return decorator
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment