22 lines
668 B
Python
22 lines
668 B
Python
from functools import wraps
|
|
from django.contrib import messages
|
|
from django.shortcuts import redirect
|
|
from django.http import HttpResponse
|
|
|
|
|
|
def Custom_is_staff_function(user):
|
|
if user.is_staff:
|
|
return True
|
|
return False
|
|
|
|
|
|
def is_staff_access(view_to_return="index"):
|
|
def decorator(view):
|
|
@wraps(view)
|
|
def _wrapped_view(request, *args, **kwargs):
|
|
if not Custom_is_staff_function(request.user):
|
|
messages.error(request, "No es personal del staff autorizado.")
|
|
return redirect(view_to_return)
|
|
return view(request, *args, **kwargs)
|
|
return _wrapped_view
|
|
return decorator |