diff options
Diffstat (limited to 'ishtar_common/utils.py')
| -rw-r--r-- | ishtar_common/utils.py | 14 | 
1 files changed, 12 insertions, 2 deletions
diff --git a/ishtar_common/utils.py b/ishtar_common/utils.py index e3a16e50b..bad4ce168 100644 --- a/ishtar_common/utils.py +++ b/ishtar_common/utils.py @@ -55,7 +55,7 @@ from django import forms  from django.apps import apps  from django.conf import settings  from django.conf.urls import url -from django.contrib.auth.models import Permission, User +from django.contrib.auth.models import Permission, User, Group  from django.contrib.auth.hashers import Argon2PasswordHasher as BaseArgon2PasswordHasher  from django.contrib.contenttypes.models import ContentType  from django.contrib.gis.geos import GEOSGeometry @@ -246,9 +246,19 @@ def check_permissions(permissions=None, redirect_url="/"):                      if ishtaruser.has_permission(permission):                          kwargs["current_right"] = permission                          return view_func(request, *args, **kwargs) +            msg = str(_("You don't have sufficient permissions to do this action.")) +            groups = Group.objects.filter(permissions__codename__in=[ +                perm.split(".")[-1] for perm in permissions +            ]) +            if groups.count(): +                msg += "<br>" + str( +                    _("If this is unexpected, the profile type attached to yours account have to add one of this group: {}. Ask the administrator of your instance.") +                ).format( +                    ", ".join(["<strong>" + str(g) + "</strong>" for g in groups]) +                )              put_session_message(                  request.session.session_key, -                _("You don't have sufficient permissions to do this action."), +                msg,                  "warning",              )              return HttpResponseRedirect(redirect_url)  | 
