__is_member.py 330 Bytes
Newer Older
1
from base_app.models import User
Florent Chehab's avatar
Florent Chehab committed
2
3
4


def is_member(group_name: str, user: User) -> bool:
5
6
7
    """
    Function to know if a user is part of a specific group.
    """
Florent Chehab's avatar
Florent Chehab committed
8
9
10
11
    return group_name in user.cached_groups
    # before:
    # When we were using the standard django model
    # return user.groups.filter(name=group_name).exists()