Source code for nkdsu.apps.vote.elfs
from django.contrib.auth.models import AnonymousUser, User
#: The name of the group that elfs belong to
ELFS_NAME = "Elfs"
[docs]
def is_elf(user: User | AnonymousUser) -> bool:
"""
Return :data:`True` if ``user`` is an elf.
"""
return user.is_authenticated and (
user.is_staff or user.groups.filter(name=ELFS_NAME).exists()
)