# HG changeset patch # User Brian Neal # Date 1261261209 0 # Node ID ef93dc9f19920bc0f434ab36be7b2ae46954504b # Parent 82deb8cc59e95b9f064d82fed27a4be9662fc0bf Implement #44 - Add age confirmation to registration form. Also added a password > 6 rule. diff -r 82deb8cc59e9 -r ef93dc9f1992 gpp/accounts/forms.py --- a/gpp/accounts/forms.py Sat Dec 19 20:12:29 2009 +0000 +++ b/gpp/accounts/forms.py Sat Dec 19 22:20:09 2009 +0000 @@ -17,15 +17,29 @@ class RegisterForm(forms.Form): """Form used to register with the website""" - username = forms.RegexField(max_length = 30, regex = r'^\w+$', - error_messages = {'invalid' : 'Your username must be 30 characters or less and contain only letters, numbers and underscores.'}) + username = forms.RegexField(max_length=30, regex = r'^\w+$', + error_messages={ + 'invalid': 'Your username must be 30 characters or less and ' \ + 'contain only letters, numbers and underscores.'}) email = forms.EmailField() password1 = forms.CharField(label = "Password", widget = forms.PasswordInput) password2 = forms.CharField(label = "Password confirmation", widget = forms.PasswordInput) - agree_tos = forms.BooleanField(required = True, label = 'I agree to the Terms of Service', - error_messages = {'required' : 'You have not agreed to our Terms of Service'}) - agree_privacy = forms.BooleanField(required = True, label = 'I agree to the Privacy Policy', - error_messages = {'required' : 'You have not agreed to our Privacy Policy'}) + agree_age = forms.BooleanField(required=True, + label='I certify that I am over the age of 13', + error_messages={ + 'required': 'Sorry, but you must be over the age of 13 to ' \ + 'register at our site.', + }) + agree_tos = forms.BooleanField(required=True, + label='I agree to the Terms of Service', + error_messages={ + 'required': 'You have not agreed to our Terms of Service.', + }) + agree_privacy = forms.BooleanField(required=True, + label='I agree to the Privacy Policy', + error_messages={ + 'required': 'You have not agreed to our Privacy Policy.', + }) def __init__(self, *args, **kwargs): self.ip = kwargs.pop('ip', '?') @@ -68,6 +82,8 @@ password2 = self.cleaned_data["password2"] if password1 != password2: self._validation_error("The two password fields didn't match.") + if len(password1) < 6: + self._validation_error("Please choose a password of 6 characters or more.") return password2 def save(self): diff -r 82deb8cc59e9 -r ef93dc9f1992 gpp/templates/accounts/register.html --- a/gpp/templates/accounts/register.html Sat Dec 19 20:12:29 2009 +0000 +++ b/gpp/templates/accounts/register.html Sat Dec 19 22:20:09 2009 +0000 @@ -9,6 +9,7 @@ only (no spaces).
  • An email address is required to use this site. A confirmation email will be sent to the address you supply, and it is necessary to complete the registration process.
  • +
  • You must be over the age of 13 years.
  • You must agree to our Terms of Service.
  • You must agree to our Privacy Policy.