konova/konova/utils/user_checks.py
mpeltriaux 6ec37dbe11 #38 User requests
* implements 3) "Extend sharing on direct adding of users"
2021-11-15 14:00:08 +01:00

37 lines
812 B
Python

"""
Author: Michel Peltriaux
Organization: Struktur- und Genehmigungsdirektion Nord, Rhineland-Palatinate, Germany
Contact: michel.peltriaux@sgdnord.rlp.de
Created on: 02.07.21
"""
from django.contrib.auth.models import User
from konova.settings import ETS_GROUP, ZB_GROUP
def in_group(user: User, group: str) -> bool:
""" Checks if the user is part of a group
Args:
user (User): The user object
group (str): The group's name
Returns:
bool
"""
return user.groups.filter(
name=group
)
def is_default_group_only(user: User) -> bool:
""" Checks if the user is only part of the default group
Args:
user (User): The user object
Returns:
bool
"""
return not in_group(user, ZB_GROUP) and not in_group(user, ETS_GROUP)