__get_user_level.py 475 Bytes
Newer Older
1
from .__is_member import is_member
2
from shared import OBJ_MODERATION_PERMISSIONS
Florent Chehab's avatar
Florent Chehab committed
3
4


5
def get_user_level(user) -> int:
Florent Chehab's avatar
Florent Chehab committed
6
7
8
9
10
    """
    TODO unit test
    """
    if user.is_staff:
        return OBJ_MODERATION_PERMISSIONS["staff"]
11
    elif is_member("DRI", user):
Florent Chehab's avatar
Florent Chehab committed
12
        return OBJ_MODERATION_PERMISSIONS["DRI"]
13
    elif is_member("Moderators", user):
Florent Chehab's avatar
Florent Chehab committed
14
15
16
        return OBJ_MODERATION_PERMISSIONS["moderator"]
    else:
        return OBJ_MODERATION_PERMISSIONS["authenticated_user"]