Move two calls to str.lower next to each other

This means that we can rewrite `validate_email_address` to do a
different comparison without having to also change `__init__`

I’ve moved the platform admin check into its own conditional to keep the
line length manageable.
This commit is contained in:
Chris Hill-Scott
2021-07-13 14:43:26 +01:00
parent aefbe7709b
commit 9dd5c89252

View File

@@ -1044,10 +1044,12 @@ class BaseInviteUserForm():
def __init__(self, invalid_email_address, *args, **kwargs):
super().__init__(*args, **kwargs)
self.invalid_email_address = invalid_email_address.lower()
self.invalid_email_address = invalid_email_address
def validate_email_address(self, field):
if field.data.lower() == self.invalid_email_address and not current_user.platform_admin:
if current_user.platform_admin:
return
if field.data.lower() == self.invalid_email_address.lower():
raise ValidationError("You cannot send an invitation to yourself")