From 4186f0fc3807feff97ddbf32404af28243728305 Mon Sep 17 00:00:00 2001 From: "John N. Milner" Date: Fri, 17 Apr 2020 14:38:34 -0400 Subject: [PATCH] Prefer `not` to `is False` and clarify message --- kpi/models/object_permission.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/kpi/models/object_permission.py b/kpi/models/object_permission.py index a92124d8d7..9024143503 100644 --- a/kpi/models/object_permission.py +++ b/kpi/models/object_permission.py @@ -729,11 +729,14 @@ def assign_perm(self, user_obj, perm, deny=False, defer_recalc=False, ): # Is an anonymous user allowed to have this permission? fq_permission = f'{app_label}.{codename}' - if deny is False and \ - fq_permission not in settings.ALLOWED_ANONYMOUS_PERMISSIONS: + if ( + not deny + and fq_permission not in settings.ALLOWED_ANONYMOUS_PERMISSIONS + ): raise ValidationError( - 'Anonymous users cannot have the permission {}.'.format( - codename) + 'Anonymous users cannot be granted the permission {}.'.format( + codename + ) ) # Get the User database representation for AnonymousUser user_obj = get_anonymous_user()