Ticket #6774: 6774.nfa.diff

File 6774.nfa.diff, 4.8 KB (added by Honza Král, 16 years ago)
  • django/contrib/auth/forms.py

    diff --git a/django/contrib/auth/forms.py b/django/contrib/auth/forms.py
    index 1997bd5..a825141 100644
    a b from django.contrib.sites.models import Site  
    44from django.template import Context, loader
    55from django.core import validators
    66from django import newforms as forms
    7 from django.utils.translation import ugettext as _
     7from django.utils.translation import ugettext_lazy as _, ugettext
    88
    99class UserCreationForm(forms.ModelForm):
    1010    """
    class UserCreationForm(forms.ModelForm):  
    2626            User.objects.get(username=username)
    2727        except User.DoesNotExist:
    2828            return username
    29         raise forms.ValidationError(_("A user with that username already exists."))
     29        raise forms.ValidationError(ugettext("A user with that username already exists."))
    3030   
    3131    def clean_password2(self):
    3232        password1 = self.cleaned_data["password1"]
    3333        password2 = self.cleaned_data["password2"]
    3434        if password1 != password2:
    35             raise forms.ValidationError(_("The two password fields didn't match."))
     35            raise forms.ValidationError(ugettext("The two password fields didn't match."))
    3636        return password2
    3737   
    3838    def save(self, commit=True):
    class AuthenticationForm(forms.Form):  
    6868        if username and password:
    6969            self.user_cache = authenticate(username=username, password=password)
    7070            if self.user_cache is None:
    71                 raise forms.ValidationError(_("Please enter a correct username and password. Note that both fields are case-sensitive."))
     71                raise forms.ValidationError(ugettext("Please enter a correct username and password. Note that both fields are case-sensitive."))
    7272            elif not self.user_cache.is_active:
    73                 raise forms.ValidationError(_("This account is inactive."))
     73                raise forms.ValidationError(ugettext("This account is inactive."))
    7474       
    7575        # TODO: determine whether this should move to its own method.
    7676        if self.request:
    7777            if not self.request.session.test_cookie_worked():
    78                 raise forms.ValidationError(_("Your Web browser doesn't appear to have cookies enabled. Cookies are required for logging in."))
     78                raise forms.ValidationError(ugettext("Your Web browser doesn't appear to have cookies enabled. Cookies are required for logging in."))
    7979       
    8080        return self.cleaned_data
    8181   
    class PasswordResetForm(forms.Form):  
    9797        email = self.cleaned_data["email"]
    9898        self.users_cache = User.objects.filter(email__iexact=email)
    9999        if len(self.users_cache) == 0:
    100             raise forms.ValidationError(_("That e-mail address doesn't have an associated user account. Are you sure you've registered?"))
     100            raise forms.ValidationError(ugettext("That e-mail address doesn't have an associated user account. Are you sure you've registered?"))
    101101   
    102102    def save(self, domain_override=None, email_template_name='registration/password_reset_email.html'):
    103103        """
    class PasswordResetForm(forms.Form):  
    122122                'site_name': site_name,
    123123                'user': user,
    124124            }
    125             send_mail(_("Password reset on %s") % site_name,
     125            send_mail(ugettext("Password reset on %s") % site_name,
    126126                t.render(Context(c)), None, [user.email])
    127127
    128128class PasswordChangeForm(forms.Form):
    class PasswordChangeForm(forms.Form):  
    143143        """
    144144        old_password = self.cleaned_data["old_password"]
    145145        if not self.user.check_password(old_password):
    146             raise forms.ValidationError(_("Your old password was entered incorrectly. Please enter it again."))
     146            raise forms.ValidationError(ugettext("Your old password was entered incorrectly. Please enter it again."))
    147147        return old_password
    148148   
    149149    def clean_new_password2(self):
    class PasswordChangeForm(forms.Form):  
    151151        password2 = self.cleaned_data.get('new_password2')
    152152        if password1 and password2:
    153153            if password1 != password2:
    154                 raise forms.ValidationError(_("The two password fields didn't match."))
     154                raise forms.ValidationError(ugettext("The two password fields didn't match."))
    155155        return password2
    156156   
    157157    def save(self, commit=True):
    class AdminPasswordChangeForm(forms.Form):  
    176176        password2 = self.cleaned_data.get('password2')
    177177        if password1 and password2:
    178178            if password1 != password2:
    179                 raise forms.ValidationError(_("The two password fields didn't match."))
     179                raise forms.ValidationError(ugettext("The two password fields didn't match."))
    180180        return password2
    181181   
    182182    def save(self, commit=True):
Back to Top