__does_user_have_moderation_rights.py 344 Bytes
Newer Older
Florent Chehab's avatar
Florent Chehab committed
1
from backend_app.utils import is_member
2
from base_app.models import User
3 4


Florent Chehab's avatar
Florent Chehab committed
5
def does_user_have_moderation_rights(user: User) -> bool:
6
    """
Florent Chehab's avatar
Florent Chehab committed
7 8
    Function to know if a user is staff or member of DRI or member of the moderator group.

9 10
    TODO unit test
    """
11
    return user.is_staff or is_member("DRI", user) or is_member("Moderators", user)