From 512f12e721ef74fbb9e7a75bda3bb51bf70d437d Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Fri, 10 Jul 2009 19:12:54 +0200 Subject: [PATCH] Make sure the form validation says something about the super user having perms. --- src/authority/forms.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/authority/forms.py b/src/authority/forms.py index 21e811d..f756cb4 100644 --- a/src/authority/forms.py +++ b/src/authority/forms.py @@ -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