pennersr/django-allauth — pull request #63 by Chez (2012-06-07 10:26:48+00:00)
Title: Tidied code to more or less PEP8 standards and added MINIMUM_PASSWORD_LENGTH into settings

I had to tidy the code to PEP8 as I use an editor that marks up the code with boxes if it isn't PEP8 standard and consequently makes it difficult for me to read. Can't hurt!

Removed a few imports that were not being used...

Added

# Password Minimum Length - Should be an integer or False
PASSWORD_MINIMUM_LENGTH = getattr(settings, "ACCOUNT_PASSWORD_MINIMUM_LENGTH", 7)

Changed Accounts/forms.py to accommodate the above

Added at the end of forms.py

def validate_password(cleaned_data, forms):
"""
Added by Chez - Checks passwords minimum length
PASSWORD_MINIMUM_LENGTH in app settings should be an integer or False
"""
if "password1" in cleaned_data and "password2" in cleaned_data:

if PASSWORD_MINIMUM_LENGTH:
if len(cleaned_data['password1']) < PASSWORD_MINIMUM_LENGTH:
raise forms.ValidationError(_("Password must be a minimum of %s characters." % PASSWORD_MINIMUM_LENGTH))

if cleaned_data['password1'] != cleaned_data['password2']:
raise forms.ValidationError(_("You must type the same password each time."))

return True