Mercurial > public > sg101
comparison gpp/accounts/forms.py @ 316:767cedc7d12a
Fixing #144; integrate with new Django logging support. Also added unit tests for Donations app.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Sun, 30 Jan 2011 20:02:32 +0000 |
parents | e3958aacd8dd |
children | efa3b4901777 |
comparison
equal
deleted
inserted
replaced
315:36373d995611 | 316:767cedc7d12a |
---|---|
22 'invalid': 'Your username must be 30 characters or less and ' \ | 22 'invalid': 'Your username must be 30 characters or less and ' \ |
23 'contain only letters, numbers and underscores.'}) | 23 'contain only letters, numbers and underscores.'}) |
24 email = forms.EmailField() | 24 email = forms.EmailField() |
25 password1 = forms.CharField(label = "Password", widget = forms.PasswordInput) | 25 password1 = forms.CharField(label = "Password", widget = forms.PasswordInput) |
26 password2 = forms.CharField(label = "Password confirmation", widget = forms.PasswordInput) | 26 password2 = forms.CharField(label = "Password confirmation", widget = forms.PasswordInput) |
27 agree_age = forms.BooleanField(required=True, | 27 agree_age = forms.BooleanField(required=True, |
28 label='I certify that I am over the age of 13', | 28 label='I certify that I am over the age of 13', |
29 error_messages={ | 29 error_messages={ |
30 'required': 'Sorry, but you must be over the age of 13 to ' \ | 30 'required': 'Sorry, but you must be over the age of 13 to ' \ |
31 'register at our site.', | 31 'register at our site.', |
32 }) | 32 }) |
33 agree_tos = forms.BooleanField(required=True, | 33 agree_tos = forms.BooleanField(required=True, |
34 label='I agree to the Terms of Service', | 34 label='I agree to the Terms of Service', |
35 error_messages={ | 35 error_messages={ |
36 'required': 'You have not agreed to our Terms of Service.', | 36 'required': 'You have not agreed to our Terms of Service.', |
37 }) | 37 }) |
38 agree_privacy = forms.BooleanField(required=True, | 38 agree_privacy = forms.BooleanField(required=True, |
94 # Send the confirmation email | 94 # Send the confirmation email |
95 | 95 |
96 site = Site.objects.get_current() | 96 site = Site.objects.get_current() |
97 admin_email = settings.ADMINS[0][1] | 97 admin_email = settings.ADMINS[0][1] |
98 | 98 |
99 activation_link = 'http://%s%s' % (site.domain, reverse('accounts.views.register_confirm', | 99 activation_link = 'http://%s%s' % (site.domain, reverse('accounts.views.register_confirm', |
100 kwargs = {'username' : pending_user.username, 'key' : pending_user.key})) | 100 kwargs = {'username' : pending_user.username, 'key' : pending_user.key})) |
101 | 101 |
102 msg = render_to_string('accounts/registration_email.txt', | 102 msg = render_to_string('accounts/registration_email.txt', |
103 { | 103 { |
104 'site_name' : site.name, | 104 'site_name' : site.name, |
110 }) | 110 }) |
111 | 111 |
112 subject = 'Registration Confirmation for ' + site.name | 112 subject = 'Registration Confirmation for ' + site.name |
113 send_mail(subject, msg, admin_email, [self.cleaned_data['email']], | 113 send_mail(subject, msg, admin_email, [self.cleaned_data['email']], |
114 expedite=True) | 114 expedite=True) |
115 logging.info('Accounts/registration conf. email sent to %s for user %s; IP = %s' % \ | 115 logging.info('Accounts/registration conf. email sent to %s for user %s; IP = %s', |
116 (self.cleaned_data['email'], pending_user.username, self.ip)) | 116 self.cleaned_data['email'], pending_user.username, self.ip) |
117 | 117 |
118 return pending_user | 118 return pending_user |
119 | 119 |
120 def _validation_error(self, msg, param=None): | 120 def _validation_error(self, msg, param=None): |
121 logging.error('Accounts/registration [%s]: %s (%s)' % (self.ip, msg, param)) | 121 logging.error('Accounts/registration [%s]: %s (%s)', self.ip, msg, param) |
122 raise forms.ValidationError(msg) | 122 raise forms.ValidationError(msg) |