From 3bee6ed05f9f1fb564db8fc6ea790c15efe19f46 Mon Sep 17 00:00:00 2001 From: Oliver Falk Date: Mon, 31 Aug 2020 09:14:05 +0200 Subject: [PATCH] Differentiate if mail has been added by yourself or someone else (in the error message) --- ivatar/ivataraccount/forms.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/ivatar/ivataraccount/forms.py b/ivatar/ivataraccount/forms.py index 21acf57..2f98dfe 100644 --- a/ivatar/ivataraccount/forms.py +++ b/ivatar/ivataraccount/forms.py @@ -62,12 +62,14 @@ class AddEmailForm(forms.Form): _('Address already added, currently unconfirmed')) return False - # Check whether or not the email is already confirmed by someone - if ConfirmedEmail.objects.filter( - email=self.cleaned_data['email']).exists(): - self.add_error( - 'email', - _('Address already confirmed (by someone else)')) + # Check whether or not the email is already confirmed (by someone) + check_mail = ConfirmedEmail.objects.filter( + email=self.cleaned_data['email']) + if check_mail.exists(): + msg = _('Address already confirmed (by someone else)') + if check_mail.first().user == request.user: + msg = _('Address already confirmed (by you)') + self.add_error('email', msg) return False unconfirmed = UnconfirmedEmail()