Mercurial > public > sg101
changeset 155:ef93dc9f1992
Implement #44 - Add age confirmation to registration form. Also added a password > 6 rule.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Sat, 19 Dec 2009 22:20:09 +0000 |
parents | 82deb8cc59e9 |
children | 7ad1f3e77cd9 |
files | gpp/accounts/forms.py gpp/templates/accounts/register.html |
diffstat | 2 files changed, 23 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- 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):
--- 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).</li> <li>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.</li> + <li>You must be over the age of 13 years.</li> <li>You must agree to our <a href="/policy/tos/" target="_blank">Terms of Service</a>.</li> <li>You must agree to our <a href="/policy/privacy/" target="_blank">Privacy Policy</a>.</li> </ul>