from django.conf import settings
from django.contrib.auth import REDIRECT_FIELD_NAME
from django.contrib.auth.decorators import user_passes_test

def employee_required(function=None, login_url='login', redirect_field_name='login'):
    def checker(user):
        return user.is_authenticated and user.is_employee
    actual_decorator = user_passes_test(
        checker,
        login_url=login_url,
        redirect_field_name=redirect_field_name
    )
    if function:
        return actual_decorator(function)
    return actual_decorator

def supervisor_required(function=None, login_url='login_employee', redirect_field_name='login_employee'):
    def checker(user):
        return user.is_authenticated and user.is_employee and user.is_supervisor
    actual_decorator = user_passes_test(
        checker,
        login_url=login_url,
        redirect_field_name=redirect_field_name
    )
    if function:
        return actual_decorator(function)
    return actual_decorator

from django.conf import settings
from django.contrib.auth import REDIRECT_FIELD_NAME
from django.contrib.auth.decorators import user_passes_test

def employee_required(function=None, login_url='login', redirect_field_name='login'):
    def checker(user):
        return user.is_authenticated and user.is_employee
    actual_decorator = user_passes_test(
        checker,
        login_url=login_url,
        redirect_field_name=redirect_field_name
    )
    if function:
        return actual_decorator(function)
    return actual_decorator

def supervisor_required(function=None, login_url='login_employee', redirect_field_name='login_employee'):
    def checker(user):
        return user.is_authenticated and user.is_employee and user.is_supervisor
    actual_decorator = user_passes_test(
        checker,
        login_url=login_url,
        redirect_field_name=redirect_field_name
    )
    if function:
        return actual_decorator(function)
    return actual_decorator
