Django

Code

Changeset 8214

Show
Ignore:
Timestamp:
08/05/08 11:36:20 (4 months ago)
Author:
lukeplant
Message:

Cleaned up whitespace

Files:

Legend:

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

    r8207 r8214  
    1717    password1 = forms.CharField(label=_("Password"), widget=forms.PasswordInput) 
    1818    password2 = forms.CharField(label=_("Password confirmation"), widget=forms.PasswordInput) 
    19      
     19 
    2020    class Meta: 
    2121        model = User 
    2222        fields = ("username",) 
    23      
     23 
    2424    def clean_username(self): 
    2525        username = self.cleaned_data["username"] 
     
    2929            return username 
    3030        raise forms.ValidationError(_("A user with that username already exists.")) 
    31      
     31 
    3232    def clean_password2(self): 
    3333        password1 = self.cleaned_data["password1"] 
     
    3636            raise forms.ValidationError(_("The two password fields didn't match.")) 
    3737        return password2 
    38      
     38 
    3939    def save(self, commit=True): 
    4040        user = super(UserCreationForm, self).save(commit=False) 
     
    5151    username = forms.CharField(label=_("Username"), max_length=30) 
    5252    password = forms.CharField(label=_("Password"), widget=forms.PasswordInput) 
    53      
     53 
    5454    def __init__(self, request=None, *args, **kwargs): 
    5555        """ 
     
    6262        self.user_cache = None 
    6363        super(AuthenticationForm, self).__init__(*args, **kwargs) 
    64      
     64 
    6565    def clean(self): 
    6666        username = self.cleaned_data.get('username') 
    6767        password = self.cleaned_data.get('password') 
    68          
     68 
    6969        if username and password: 
    7070            self.user_cache = authenticate(username=username, password=password) 
     
    7373            elif not self.user_cache.is_active: 
    7474                raise forms.ValidationError(_("This account is inactive.")) 
    75          
     75 
    7676        # TODO: determine whether this should move to its own method. 
    7777        if self.request: 
    7878            if not self.request.session.test_cookie_worked(): 
    7979                raise forms.ValidationError(_("Your Web browser doesn't appear to have cookies enabled. Cookies are required for logging in.")) 
    80          
     80 
    8181        return self.cleaned_data 
    82      
     82 
    8383    def get_user_id(self): 
    8484        if self.user_cache: 
    8585            return self.user_cache.id 
    8686        return None 
    87      
     87 
    8888    def get_user(self): 
    8989        return self.user_cache 
     
    9191class PasswordResetForm(forms.Form): 
    9292    email = forms.EmailField(label=_("E-mail"), max_length=75) 
    93      
     93 
    9494    def clean_email(self): 
    9595        """ 
     
    152152            self.user.save() 
    153153        return self.user 
    154      
     154 
    155155class PasswordChangeForm(SetPasswordForm): 
    156156    """ 
     
    159159    """ 
    160160    old_password = forms.CharField(label=_("Old password"), widget=forms.PasswordInput) 
    161      
     161 
    162162    def clean_old_password(self): 
    163163        """ 
     
    169169        return old_password 
    170170PasswordChangeForm.base_fields.keyOrder = ['old_password', 'new_password1', 'new_password2'] 
    171      
     171 
    172172class AdminPasswordChangeForm(forms.Form): 
    173173    """ 
     
    176176    password1 = forms.CharField(label=_("Password"), widget=forms.PasswordInput) 
    177177    password2 = forms.CharField(label=_("Password (again)"), widget=forms.PasswordInput) 
    178      
     178 
    179179    def __init__(self, user, *args, **kwargs): 
    180180        self.user = user 
    181181        super(AdminPasswordChangeForm, self).__init__(*args, **kwargs) 
    182      
     182 
    183183    def clean_password2(self): 
    184184        password1 = self.cleaned_data.get('password1') 
     
    188188                raise forms.ValidationError(_("The two password fields didn't match.")) 
    189189        return password2 
    190      
     190 
    191191    def save(self, commit=True): 
    192192        """