Missing group message
* adds group checker decorator for adding a message informing about missing group privileges
This commit is contained in:
@@ -46,6 +46,25 @@ def superuser_required(function):
|
||||
return wrap
|
||||
|
||||
|
||||
def any_group_check(function):
|
||||
"""
|
||||
Checks for any group membership. Adds a message in case of having none.
|
||||
|
||||
"""
|
||||
@wraps(function)
|
||||
def wrap(request, *args, **kwargs):
|
||||
user = request.user
|
||||
# Inform user about missing group privileges!
|
||||
groups = user.groups.all()
|
||||
if not groups:
|
||||
messages.info(
|
||||
request,
|
||||
_("+++ Attention: You are not part of any group. You won't be able to create, edit or do anything. Please contact an administrator. +++")
|
||||
)
|
||||
return function(request, *args, **kwargs)
|
||||
return wrap
|
||||
|
||||
|
||||
def default_group_required(function):
|
||||
"""
|
||||
A decorator for functions which shall only be usable for users of specific groups.
|
||||
|
||||
Reference in New Issue
Block a user