Django

Code

Changeset 8542

Show
Ignore:
Timestamp:
08/25/08 11:55:57 (3 months ago)
Author:
jacob
Message:

Fixed #7833: the user creation form now works when password1 isn't set.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/django/contrib/auth/forms.py

    r8214 r8542  
    3131 
    3232    def clean_password2(self): 
    33         password1 = self.cleaned_data["password1"] 
     33        password1 = self.cleaned_data.get("password1", "") 
    3434        password2 = self.cleaned_data["password2"] 
    3535        if password1 != password2: 
  • django/trunk/django/contrib/auth/tests/forms.py

    r8162 r8542  
    55>>> from django.contrib.auth.forms import PasswordChangeForm, SetPasswordForm 
    66 
    7 The user already exists. 
     7# The user already exists. 
    88 
    99>>> user = User.objects.create_user("jsmith", "jsmith@example.com", "test123") 
     
    1919[u'A user with that username already exists.'] 
    2020 
    21 The username contains invalid data. 
     21# The username contains invalid data. 
    2222 
    2323>>> data = { 
     
    3232[u'This value must contain only letters, numbers and underscores.'] 
    3333 
    34 The verification password is incorrect. 
     34# The verification password is incorrect. 
    3535 
    3636>>> data = { 
     
    4545[u"The two password fields didn't match."] 
    4646 
    47 The success case. 
     47# One (or both) passwords weren't given 
     48 
     49>>> data = {'username': 'jsmith2'} 
     50>>> form = UserCreationForm(data) 
     51>>> form.is_valid() 
     52False 
     53>>> form['password1'].errors 
     54[u'This field is required.'] 
     55>>> form['password2'].errors 
     56[u'This field is required.'] 
     57 
     58>>> data['password2'] = 'test123' 
     59>>> form = UserCreationForm(data) 
     60>>> form.is_valid() 
     61False 
     62>>> form['password1'].errors 
     63[u'This field is required.'] 
     64 
     65# The success case. 
    4866 
    4967>>> data = { 
     
    5876<User: jsmith2> 
    5977 
    60 The user submits an invalid username. 
     78# The user submits an invalid username. 
    6179 
    6280>>> data = { 
     
    7189[u'Please enter a correct username and password. Note that both fields are case-sensitive.'] 
    7290 
    73 The user is inactive. 
     91# The user is inactive. 
    7492 
    7593>>> data = { 
     
    88106>>> user.save() 
    89107 
    90 The success case 
     108# The success case 
    91109 
    92110>>> form = AuthenticationForm(None, data) 
     
    96114[] 
    97115 
    98 SetPasswordForm: 
     116### SetPasswordForm: 
    99117 
    100 The two new passwords do not match. 
     118# The two new passwords do not match. 
    101119 
    102120>>> data = { 
     
    110128[u"The two password fields didn't match."] 
    111129 
    112 The success case. 
     130# The success case. 
    113131 
    114132>>> data = { 
     
    120138True 
    121139 
    122 PasswordChangeForm: 
     140### PasswordChangeForm: 
    123141 
    124142The old password is incorrect. 
     
    135153[u'Your old password was entered incorrectly. Please enter it again.'] 
    136154 
    137 The two new passwords do not match. 
     155# The two new passwords do not match. 
    138156 
    139157>>> data = { 
     
    148166[u"The two password fields didn't match."] 
    149167 
    150 The success case. 
     168# The success case. 
    151169 
    152170>>> data = { 
     
    159177True 
    160178 
    161 Regression test - check the order of fields: 
     179# Regression test - check the order of fields: 
    162180 
    163181>>> PasswordChangeForm(user, {}).fields.keys()