mirror of
https://github.com/django/django.git
synced 2025-10-27 07:36:08 +00:00
Copied django.forms to django.oldforms and changed all code to reference django.oldforms instead of django.forms. Updated docs/forms.txt to add 'Forwards-compatibility' section that says you should not be using django.oldforms for any new projects.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@4208 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
@@ -3,16 +3,16 @@ from django.contrib.auth import authenticate
|
||||
from django.contrib.sites.models import Site
|
||||
from django.template import Context, loader
|
||||
from django.core import validators
|
||||
from django import forms
|
||||
from django import oldforms
|
||||
|
||||
class UserCreationForm(forms.Manipulator):
|
||||
class UserCreationForm(oldforms.Manipulator):
|
||||
"A form that creates a user, with no privileges, from the given username and password."
|
||||
def __init__(self):
|
||||
self.fields = (
|
||||
forms.TextField(field_name='username', length=30, maxlength=30, is_required=True,
|
||||
oldforms.TextField(field_name='username', length=30, maxlength=30, is_required=True,
|
||||
validator_list=[validators.isAlphaNumeric, self.isValidUsername]),
|
||||
forms.PasswordField(field_name='password1', length=30, maxlength=60, is_required=True),
|
||||
forms.PasswordField(field_name='password2', length=30, maxlength=60, is_required=True,
|
||||
oldforms.PasswordField(field_name='password1', length=30, maxlength=60, is_required=True),
|
||||
oldforms.PasswordField(field_name='password2', length=30, maxlength=60, is_required=True,
|
||||
validator_list=[validators.AlwaysMatchesOtherField('password1', _("The two password fields didn't match."))]),
|
||||
)
|
||||
|
||||
@@ -27,7 +27,7 @@ class UserCreationForm(forms.Manipulator):
|
||||
"Creates the user."
|
||||
return User.objects.create_user(new_data['username'], '', new_data['password1'])
|
||||
|
||||
class AuthenticationForm(forms.Manipulator):
|
||||
class AuthenticationForm(oldforms.Manipulator):
|
||||
"""
|
||||
Base class for authenticating users. Extend this to get a form that accepts
|
||||
username/password logins.
|
||||
@@ -41,9 +41,9 @@ class AuthenticationForm(forms.Manipulator):
|
||||
"""
|
||||
self.request = request
|
||||
self.fields = [
|
||||
forms.TextField(field_name="username", length=15, maxlength=30, is_required=True,
|
||||
oldforms.TextField(field_name="username", length=15, maxlength=30, is_required=True,
|
||||
validator_list=[self.isValidUser, self.hasCookiesEnabled]),
|
||||
forms.PasswordField(field_name="password", length=15, maxlength=30, is_required=True),
|
||||
oldforms.PasswordField(field_name="password", length=15, maxlength=30, is_required=True),
|
||||
]
|
||||
self.user_cache = None
|
||||
|
||||
@@ -68,11 +68,11 @@ class AuthenticationForm(forms.Manipulator):
|
||||
def get_user(self):
|
||||
return self.user_cache
|
||||
|
||||
class PasswordResetForm(forms.Manipulator):
|
||||
class PasswordResetForm(oldforms.Manipulator):
|
||||
"A form that lets a user request a password reset"
|
||||
def __init__(self):
|
||||
self.fields = (
|
||||
forms.EmailField(field_name="email", length=40, is_required=True,
|
||||
oldforms.EmailField(field_name="email", length=40, is_required=True,
|
||||
validator_list=[self.isValidUserEmail]),
|
||||
)
|
||||
|
||||
@@ -105,16 +105,16 @@ class PasswordResetForm(forms.Manipulator):
|
||||
}
|
||||
send_mail('Password reset on %s' % site_name, t.render(Context(c)), None, [self.user_cache.email])
|
||||
|
||||
class PasswordChangeForm(forms.Manipulator):
|
||||
class PasswordChangeForm(oldforms.Manipulator):
|
||||
"A form that lets a user change his password."
|
||||
def __init__(self, user):
|
||||
self.user = user
|
||||
self.fields = (
|
||||
forms.PasswordField(field_name="old_password", length=30, maxlength=30, is_required=True,
|
||||
oldforms.PasswordField(field_name="old_password", length=30, maxlength=30, is_required=True,
|
||||
validator_list=[self.isValidOldPassword]),
|
||||
forms.PasswordField(field_name="new_password1", length=30, maxlength=30, is_required=True,
|
||||
oldforms.PasswordField(field_name="new_password1", length=30, maxlength=30, is_required=True,
|
||||
validator_list=[validators.AlwaysMatchesOtherField('new_password2', _("The two 'new password' fields didn't match."))]),
|
||||
forms.PasswordField(field_name="new_password2", length=30, maxlength=30, is_required=True),
|
||||
oldforms.PasswordField(field_name="new_password2", length=30, maxlength=30, is_required=True),
|
||||
)
|
||||
|
||||
def isValidOldPassword(self, new_data, all_data):
|
||||
|
||||
Reference in New Issue
Block a user