From c988cf2c41ad57211ac4f945efe5028dc1d56115 Mon Sep 17 00:00:00 2001 From: rodrigosiqueira Date: Thu, 26 Mar 2015 11:38:23 -0300 Subject: [PATCH] Changed error message for already registered email. --- colab/accounts/forms.py | 13 +++++++++++++ 1 file changed, 13 insertions(+), 0 deletions(-) diff --git a/colab/accounts/forms.py b/colab/accounts/forms.py index 113c5fd..e735f30 100644 --- a/colab/accounts/forms.py +++ b/colab/accounts/forms.py @@ -12,6 +12,9 @@ from django.utils.encoding import force_bytes from django.utils.http import urlsafe_base64_encode from django.utils.text import capfirst from django.utils.translation import ugettext_lazy as _ +from django.core.validators import validate_email +from django.core.exceptions import ValidationError +from django.utils.safestring import mark_safe from conversejs.models import XMPPAccount @@ -59,6 +62,16 @@ class UserForm(forms.ModelForm): if field_name in UserForm.required: field.required = True + def clean_email(self): + email = self.cleaned_data.get('email') + username = self.cleaned_data.get('username') + + if email and User.objects.filter(email=email).exclude( + username=username).count(): + raise forms.ValidationError( + mark_safe("Try login in: sign in")) + return email + def clean_username(self): username = self.cleaned_data["username"].strip() if not username: -- libgit2 0.21.2