Changeset 1408
- Timestamp:
- 08/13/2008 08:52:10 PM (11 months ago)
- Files:
-
- satchmo/trunk/satchmo/accounts/forms.py (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
satchmo/trunk/satchmo/accounts/forms.py
r1348 r1408 4 4 from django.dispatch import dispatcher 5 5 from django.utils.translation import ugettext_lazy as _, ugettext 6 from mail import send_welcome_email6 from satchmo.accounts.mail import send_welcome_email 7 7 from satchmo.configuration import config_value 8 8 from satchmo.contact.models import Contact … … 16 16 class RegistrationForm(forms.Form): 17 17 """The basic account registration form.""" 18 email = forms.EmailField(label=_('Email address'), 18 email = forms.EmailField(label=_('Email address'), 19 19 max_length=30, required=True) 20 password2 = forms.CharField(label=_('Password (again)'), 20 password2 = forms.CharField(label=_('Password (again)'), 21 21 max_length=30, widget=forms.PasswordInput(), required=True) 22 password1 = forms.CharField(label=_('Password'), 22 password1 = forms.CharField(label=_('Password'), 23 23 max_length=30, widget=forms.PasswordInput(), required=True) 24 first_name = forms.CharField(label=_('First name'), 24 first_name = forms.CharField(label=_('First name'), 25 25 max_length=30, required=True) 26 last_name = forms.CharField(label=_('Last name'), 26 last_name = forms.CharField(label=_('Last name'), 27 27 max_length=30, required=True) 28 28 29 newsletter = forms.BooleanField(label=_('Newsletter'), 29 newsletter = forms.BooleanField(label=_('Newsletter'), 30 30 widget=forms.CheckboxInput(), required=False) 31 32 def clean_password (self):31 32 def clean_password1(self): 33 33 """Enforce that password and password2 are the same.""" 34 34 p1 = self.cleaned_data.get('password1') … … 38 38 ugettext("The two passwords do not match.")) 39 39 40 # note, here is where we'd put some kind of custom 40 # note, here is where we'd put some kind of custom 41 41 # validator to enforce "hard" passwords. 42 42 return p1 … … 50 50 51 51 return email 52 52 53 53 def save(self, request): 54 54 """Create the contact and user described on the form. Returns the 55 55 `contact`. 56 56 """ 57 57 58 58 data = self.cleaned_data 59 59 password = data['password1'] … … 80 80 try: 81 81 contact = Contact.objects.from_request(request, create=False) 82 82 83 83 except Contact.DoesNotExist: 84 84 contact = Contact() … … 87 87 contact.first_name = first_name 88 88 contact.last_name = last_name 89 contact.email = email 89 contact.email = email 90 90 contact.role = 'Customer' 91 91 contact.save() 92 92 93 93 if 'newsletter' not in data: 94 94 subscribed = False 95 95 else: 96 96 subscribed = data['newsletter'] 97 97 98 98 dispatcher.send(signal=signals.satchmo_registration, contact=contact, subscribed=subscribed, data=data) 99 99 100 100 if not verify: 101 101 user = authenticate(username=username, password=password) … … 103 103 send_welcome_email(email, first_name, last_name) 104 104 dispatcher.send(signal=signals.satchmo_registration_verified, contact=contact) 105 105 106 106 return contact 107 107
