def clean(self): """ Make sure email is not already in the system. """ cleaned_data = super(InviteMemberForm, self).clean() email = cleaned_data.get('email') validate_email_availability(email) return cleaned_data
def clean(self): """ - Check that the user id is valid. - If the moderator changes the email, make sure the new email is not already in the system. """ cleaned_data = super(ReInviteMemberForm, self).clean() email = cleaned_data.get('email') user_id = cleaned_data.get('user_id') user = get_object_or_404(User, id=user_id) if (user.moderator != self.logged_in_moderator or not user.is_invited_pending_activation()): raise Http404 # If this email is not already registered to this user if email != user.email: validate_email_availability(email) return cleaned_data