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:
mipel 2021-07-02 10:08:00 +02:00
parent 57d97150f2
commit 92701eda40
2 changed files with 22 additions and 1 deletions

View 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")

View File

@ -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)