# staff/templatetags/staff_tags.py
from django import template

register = template.Library()

@register.filter
def get_role_badge(role):
    """Return appropriate badge class for role"""
    badges = {
        'proprietor': 'badge-danger',
        'head_master': 'badge-warning',
        'head_mistress': 'badge-warning',
        'bursar': 'badge-info',
        'teacher': 'badge-success',
        'driver': 'badge-secondary',
    }
    return badges.get(role, 'badge-primary')

@register.filter
def get_initial(name):
    """Get first letter of name for avatar"""
    if name:
        return name[0].upper()
    return '?'

@register.simple_tag
def staff_count_by_role(role):
    """Get count of staff by role"""
    from staff.models import Staff
    return Staff.objects.filter(role=role, is_active=True).count()