mirror of
https://github.com/jazzband/django-authority.git
synced 2026-04-10 18:21:00 +00:00
Make sure the form validation says something about the super user having perms.
This commit is contained in:
parent
b7ebf0022c
commit
512f12e721
1 changed files with 7 additions and 3 deletions
|
|
@ -44,11 +44,15 @@ class UserPermissionForm(BasePermissionForm):
|
|||
_("A user with that username does not exist."))
|
||||
check = permissions.BasePermission(user=user)
|
||||
if check.has_perm(self.perm, self.obj):
|
||||
raise forms.ValidationError(
|
||||
_("This user already has the permission '%(perm)s' for %(object_name)s '%(obj)s'") % {
|
||||
'perm': self.perm,
|
||||
if user.is_superuser:
|
||||
error_msg = _("The super user %(user)s already has the permission '%(perm)s' for %(object_name)s '%(obj)s'")
|
||||
else:
|
||||
error_msg = _("The user %(user)s already has the permission '%(perm)s' for %(object_name)s '%(obj)s'")
|
||||
raise forms.ValidationError(error_msg % {
|
||||
'object_name': self.obj._meta.object_name.lower(),
|
||||
'perm': self.perm,
|
||||
'obj': self.obj,
|
||||
'user': user,
|
||||
})
|
||||
return user
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue