You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

14 lines
514 B
Python

from functools import wraps
from django.shortcuts import redirect
from .models import *
def staff_login_required(view_func):
@wraps(view_func)
def _wrapped_view(request, *args, **kwargs):
# Check if the user is logged in and is a staff member
if not request.user.is_authenticated or not StaffProfile.objects.filter(user=request.user):
return redirect('signout') # Redirect to login URL if not staff
return view_func(request, *args, **kwargs)
return _wrapped_view