# core/permissions.py
"""
Permission constants and helpers for Rapha-Bethel BNPS
"""

ROLE_HIERARCHY = {
    'proprietor': 100,
    'head_master': 90,
    'head_mistress': 90,
    'bursar': 80,
    'admin': 70,
    'teacher': 60,
    'class_teacher': 60,
    'subject_teacher': 50,
    'assistant': 40,
    'support': 30,
}

def has_permission(user, required_level):
    """Check if user has required permission level"""
    if user.is_superuser:
        return True
    if hasattr(user, 'staff_profile'):
        return ROLE_HIERARCHY.get(user.staff_profile.role, 0) >= required_level
    return False