mpeltriaux
02970b19b4
* refactors django User model to custom User model to provide further attributes and methods directly on the user model
37 lines
797 B
Python
37 lines
797 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 user.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) |