Site Sections: Satchmo Main | Wiki | Demo Store |

Changeset 1408

Show
Ignore:
Timestamp:
08/13/2008 08:52:10 PM (11 months ago)
Author:
jshaffer
Message:

Rename the password clean method on RegistrationForm? so that it actually gets executed. Thanks, emes for the patch.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • satchmo/trunk/satchmo/accounts/forms.py

    r1348 r1408  
    44from django.dispatch import dispatcher 
    55from django.utils.translation import ugettext_lazy as _, ugettext 
    6 from mail import send_welcome_email 
     6from satchmo.accounts.mail import send_welcome_email 
    77from satchmo.configuration import config_value 
    88from satchmo.contact.models import Contact 
     
    1616class RegistrationForm(forms.Form): 
    1717    """The basic account registration form.""" 
    18     email = forms.EmailField(label=_('Email address'),  
     18    email = forms.EmailField(label=_('Email address'), 
    1919        max_length=30, required=True) 
    20     password2 = forms.CharField(label=_('Password (again)'),  
     20    password2 = forms.CharField(label=_('Password (again)'), 
    2121        max_length=30, widget=forms.PasswordInput(), required=True) 
    22     password1 = forms.CharField(label=_('Password'),  
     22    password1 = forms.CharField(label=_('Password'), 
    2323        max_length=30, widget=forms.PasswordInput(), required=True) 
    24     first_name = forms.CharField(label=_('First name'),  
     24    first_name = forms.CharField(label=_('First name'), 
    2525        max_length=30, required=True) 
    26     last_name = forms.CharField(label=_('Last name'),  
     26    last_name = forms.CharField(label=_('Last name'), 
    2727        max_length=30, required=True) 
    2828 
    29     newsletter = forms.BooleanField(label=_('Newsletter'),  
     29    newsletter = forms.BooleanField(label=_('Newsletter'), 
    3030        widget=forms.CheckboxInput(), required=False) 
    31          
    32     def clean_password(self): 
     31 
     32    def clean_password1(self): 
    3333        """Enforce that password and password2 are the same.""" 
    3434        p1 = self.cleaned_data.get('password1') 
     
    3838                ugettext("The two passwords do not match.")) 
    3939 
    40         # note, here is where we'd put some kind of custom  
     40        # note, here is where we'd put some kind of custom 
    4141        # validator to enforce "hard" passwords. 
    4242        return p1 
     
    5050 
    5151        return email 
    52          
     52 
    5353    def save(self, request): 
    5454        """Create the contact and user described on the form.  Returns the 
    5555        `contact`. 
    5656        """ 
    57          
     57 
    5858        data = self.cleaned_data 
    5959        password = data['password1'] 
     
    8080        try: 
    8181            contact = Contact.objects.from_request(request, create=False) 
    82              
     82 
    8383        except Contact.DoesNotExist: 
    8484            contact = Contact() 
     
    8787        contact.first_name = first_name 
    8888        contact.last_name = last_name 
    89         contact.email = email                 
     89        contact.email = email 
    9090        contact.role = 'Customer' 
    9191        contact.save() 
    92          
     92 
    9393        if 'newsletter' not in data: 
    9494            subscribed = False 
    9595        else: 
    9696            subscribed = data['newsletter'] 
    97          
     97 
    9898        dispatcher.send(signal=signals.satchmo_registration, contact=contact, subscribed=subscribed, data=data) 
    99          
     99 
    100100        if not verify: 
    101101            user = authenticate(username=username, password=password) 
     
    103103            send_welcome_email(email, first_name, last_name) 
    104104            dispatcher.send(signal=signals.satchmo_registration_verified, contact=contact) 
    105              
     105 
    106106        return contact 
    107                  
     107