"""
Template tags for admin verification notifications.
"""
from django import template
from accounts.models import User

register = template.Library()


def _pending_verification_queryset():
    return User.objects.filter(
        is_verified=False,
        id_card_image__isnull=False,
        selfie_image__isnull=False,
    ).exclude(id_card_image='').exclude(selfie_image='').order_by('-updated_at')


@register.simple_tag
def get_pending_verification_count():
    """
    Return the total number of pending verification requests.
    """
    return _pending_verification_queryset().count()


@register.simple_tag
def get_pending_verification_requests(limit=5):
    """
    Return a limited queryset of users waiting for verification.
    """
    return _pending_verification_queryset()[: int(limit)]


@register.simple_tag
def get_first_pending_verification_request():
    """
    Return the first user waiting for verification.
    """
    return _pending_verification_queryset().first()
