Change loglevel of validation errors

This commit is contained in:
Adarnof 2016-02-25 16:50:55 -05:00
parent 3b7d361595
commit bf89c4643c

View File

@ -15,29 +15,29 @@ class RegistrationForm(forms.Form):
def clean(self):
if ' ' in self.cleaned_data['username']:
logger.error("RegistrationForm username contains spaces. Raising ValidationError. Username: %s" % self.cleaned_data['username'])
logger.debug("RegistrationForm username contains spaces. Raising ValidationError. Username: %s" % self.cleaned_data['username'])
raise forms.ValidationError(u'Username cannot contain a space')
# We attempt to get the user object if we succeed we know email as been used
try:
User.objects.get(email=self.cleaned_data['email'])
logger.error("RegistrationForm email already registered. Raising ValidationError")
logger.debug("RegistrationForm email already registered. Raising ValidationError")
raise forms.ValidationError(u'Email as already been used')
except:
pass
if not re.match("^\w+$", self.cleaned_data['username']):
logger.error("RegistrationForm username contains non-alphanumeric characters. Raising ValueError. Username: %s" % self.cleaned_data['username'])
logger.debug("RegistrationForm username contains non-alphanumeric characters. Raising ValueError. Username: %s" % self.cleaned_data['username'])
raise forms.ValidationError(u'Username contains illegal characters')
if 'password' in self.cleaned_data and 'password_again' in self.cleaned_data:
if self.cleaned_data['password'] != self.cleaned_data['password_again']:
logger.error("RegistrationForm password mismatch. Raising ValueError")
logger.debug("RegistrationForm password mismatch. Raising ValueError")
raise forms.ValidationError(u'Passwords do not match')
if 'email' in self.cleaned_data and 'email_again' in self.cleaned_data:
if self.cleaned_data['email'] != self.cleaned_data['email_again']:
logger.error("RegistrationForm email mismatch. Raising ValidationError")
logger.debug("RegistrationForm email mismatch. Raising ValidationError")
raise forms.ValidationError(u'Emails do not match')
return self.cleaned_data