Permission rethinking
* No detailed permissions due to django constraints on model-based permissions * instead: logic controlled permission by group membership * adds translations
This commit is contained in:
parent
c2a066fc71
commit
d086bb9465
21
konova/utils/user_checks.py
Normal file
21
konova/utils/user_checks.py
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
"""
|
||||||
|
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
|
||||||
|
|
||||||
|
|
||||||
|
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 group in user.groups.values("name")
|
@ -41,4 +41,4 @@ def home_view(request: HttpRequest):
|
|||||||
|
|
||||||
additional_context = {}
|
additional_context = {}
|
||||||
context = BaseContext(request, additional_context).context
|
context = BaseContext(request, additional_context).context
|
||||||
return render(request, template, context)
|
return render(request, template, context)
|
||||||
|
Loading…
Reference in New Issue
Block a user