From f8d4617672e4d6a1cbaf062974d6d51d0d24b7a3 Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Tue, 13 Jul 2021 14:38:13 +0100 Subject: [PATCH] Refactor organisation invite form for reuse MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It’s exactly the same code as `BaseInviteUserForm` so there’s really no need to duplicate it (and means that changes we make to `BaseInviteUserForm` in the future will get inherited). --- app/main/forms.py | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/app/main/forms.py b/app/main/forms.py index d0685d7dd..ea8d7a613 100644 --- a/app/main/forms.py +++ b/app/main/forms.py @@ -1066,16 +1066,8 @@ class BroadcastInviteUserForm(BaseInviteUserForm, BroadcastPermissionsForm): raise ValidationError("You cannot send an invitation to yourself") -class InviteOrgUserForm(StripWhitespaceForm): - email_address = email_address(gov_user=False) - - def __init__(self, inviter_email_address, *args, **kwargs): - super(InviteOrgUserForm, self).__init__(*args, **kwargs) - self.inviter_email_address = inviter_email_address.lower() - - def validate_email_address(self, field): - if field.data.lower() == self.inviter_email_address and not current_user.platform_admin: - raise ValidationError("You cannot send an invitation to yourself") +class InviteOrgUserForm(BaseInviteUserForm, StripWhitespaceForm): + pass class TwoFactorForm(StripWhitespaceForm):