magic-removal: Moved django.core.formfields to django.forms and updated references. Also fixed #1222.
git-svn-id: http://code.djangoproject.com/svn/django/branches/magic-removal@1956 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
c50968fa0e
commit
aba6d189d3
|
@ -1,7 +1,6 @@
|
|||
# Generic admin views.
|
||||
from django.conf import settings
|
||||
from django.contrib.admin.views.decorators import staff_member_required
|
||||
from django.core import formfields
|
||||
from django import template
|
||||
from django.template import loader
|
||||
from django.db import models
|
||||
|
|
|
@ -2,7 +2,7 @@ from django.contrib.admin.models import LogEntry
|
|||
from django.contrib.admin.views.decorators import staff_member_required
|
||||
from django.contrib.admin.views.main import get_model_and_app
|
||||
from django.contrib.admin.views.stages.modify import render_change_form
|
||||
from django.core import formfields
|
||||
from django import forms
|
||||
from django import template
|
||||
from django.http import Http404
|
||||
from django.core.exceptions import ImproperlyConfigured, ObjectDoesNotExist, PermissionDenied
|
||||
|
@ -79,7 +79,7 @@ def add_stage(request, path, show_delete=False, form_url='', post_url='../', pos
|
|||
errors = {}
|
||||
|
||||
# Populate the FormWrapper.
|
||||
form = formfields.FormWrapper(manipulator, new_data, errors)
|
||||
form = forms.FormWrapper(manipulator, new_data, errors)
|
||||
|
||||
c = Context(request, {
|
||||
'title': _('Add %s') % opts.verbose_name,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
from django.contrib.admin.views.main import get_model_and_app
|
||||
from django.core import formfields
|
||||
from django import forms
|
||||
from django import template
|
||||
from django.http import Http404
|
||||
from django.core.exceptions import ImproperlyConfigured, ObjectDoesNotExist, PermissionDenied
|
||||
|
@ -93,7 +93,7 @@ def change_stage(request, path, object_id):
|
|||
errors = {}
|
||||
|
||||
# Populate the FormWrapper.
|
||||
form = formfields.FormWrapper(manipulator, new_data, errors)
|
||||
form = forms.FormWrapper(manipulator, new_data, errors)
|
||||
form.original = manipulator.original_object
|
||||
form.order_objects = []
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
from django.contrib.admin.views.decorators import staff_member_required
|
||||
from django.core import formfields, validators
|
||||
from django import template
|
||||
from django.core import validators
|
||||
from django import template, forms
|
||||
from django.template import loader
|
||||
from django.template import RequestContext as Context
|
||||
from django.core.extensions import render_to_response
|
||||
|
@ -26,17 +26,17 @@ def template_validator(request):
|
|||
request.user.add_message('The template is valid.')
|
||||
return render_to_response('admin/template_validator', {
|
||||
'title': 'Template validator',
|
||||
'form': formfields.FormWrapper(manipulator, new_data, errors),
|
||||
'form': forms.FormWrapper(manipulator, new_data, errors),
|
||||
}, context_instance=RequestContext(request))
|
||||
template_validator = staff_member_required(template_validator)
|
||||
|
||||
class TemplateValidator(formfields.Manipulator):
|
||||
class TemplateValidator(forms.Manipulator):
|
||||
def __init__(self, settings_modules):
|
||||
self.settings_modules = settings_modules
|
||||
site_list = Site.objects.get_in_bulk(settings_modules.keys()).values()
|
||||
self.fields = (
|
||||
formfields.SelectField('site', is_required=True, choices=[(s.id, s.name) for s in site_list]),
|
||||
formfields.LargeTextField('template', is_required=True, rows=25, validator_list=[self.isValidTemplate]),
|
||||
forms.SelectField('site', is_required=True, choices=[(s.id, s.name) for s in site_list]),
|
||||
forms.LargeTextField('template', is_required=True, rows=25, validator_list=[self.isValidTemplate]),
|
||||
)
|
||||
|
||||
def isValidTemplate(self, field_data, all_data):
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
from django.core import formfields, validators
|
||||
from django.core import validators
|
||||
from django import forms
|
||||
from django.core.mail import mail_admins, mail_managers
|
||||
from django.http import Http404
|
||||
from django.core.exceptions import ObjectDoesNotExist
|
||||
|
@ -28,37 +29,37 @@ class PublicCommentManipulator(AuthenticationForm):
|
|||
else:
|
||||
return []
|
||||
self.fields.extend([
|
||||
formfields.LargeTextField(field_name="comment", maxlength=3000, is_required=True,
|
||||
forms.LargeTextField(field_name="comment", maxlength=3000, is_required=True,
|
||||
validator_list=[self.hasNoProfanities]),
|
||||
formfields.RadioSelectField(field_name="rating1", choices=choices,
|
||||
forms.RadioSelectField(field_name="rating1", choices=choices,
|
||||
is_required=ratings_required and num_rating_choices > 0,
|
||||
validator_list=get_validator_list(1),
|
||||
),
|
||||
formfields.RadioSelectField(field_name="rating2", choices=choices,
|
||||
forms.RadioSelectField(field_name="rating2", choices=choices,
|
||||
is_required=ratings_required and num_rating_choices > 1,
|
||||
validator_list=get_validator_list(2),
|
||||
),
|
||||
formfields.RadioSelectField(field_name="rating3", choices=choices,
|
||||
forms.RadioSelectField(field_name="rating3", choices=choices,
|
||||
is_required=ratings_required and num_rating_choices > 2,
|
||||
validator_list=get_validator_list(3),
|
||||
),
|
||||
formfields.RadioSelectField(field_name="rating4", choices=choices,
|
||||
forms.RadioSelectField(field_name="rating4", choices=choices,
|
||||
is_required=ratings_required and num_rating_choices > 3,
|
||||
validator_list=get_validator_list(4),
|
||||
),
|
||||
formfields.RadioSelectField(field_name="rating5", choices=choices,
|
||||
forms.RadioSelectField(field_name="rating5", choices=choices,
|
||||
is_required=ratings_required and num_rating_choices > 4,
|
||||
validator_list=get_validator_list(5),
|
||||
),
|
||||
formfields.RadioSelectField(field_name="rating6", choices=choices,
|
||||
forms.RadioSelectField(field_name="rating6", choices=choices,
|
||||
is_required=ratings_required and num_rating_choices > 5,
|
||||
validator_list=get_validator_list(6),
|
||||
),
|
||||
formfields.RadioSelectField(field_name="rating7", choices=choices,
|
||||
forms.RadioSelectField(field_name="rating7", choices=choices,
|
||||
is_required=ratings_required and num_rating_choices > 6,
|
||||
validator_list=get_validator_list(7),
|
||||
),
|
||||
formfields.RadioSelectField(field_name="rating8", choices=choices,
|
||||
forms.RadioSelectField(field_name="rating8", choices=choices,
|
||||
is_required=ratings_required and num_rating_choices > 7,
|
||||
validator_list=get_validator_list(8),
|
||||
),
|
||||
|
@ -117,13 +118,13 @@ class PublicCommentManipulator(AuthenticationForm):
|
|||
mail_managers("Comment posted by sketchy user (%s)" % self.user_cache.username, c.get_as_text())
|
||||
return c
|
||||
|
||||
class PublicFreeCommentManipulator(formfields.Manipulator):
|
||||
class PublicFreeCommentManipulator(forms.Manipulator):
|
||||
"Manipulator that handles public free (unregistered) comments"
|
||||
def __init__(self):
|
||||
self.fields = (
|
||||
formfields.TextField(field_name="person_name", maxlength=50, is_required=True,
|
||||
forms.TextField(field_name="person_name", maxlength=50, is_required=True,
|
||||
validator_list=[self.hasNoProfanities]),
|
||||
formfields.LargeTextField(field_name="comment", maxlength=3000, is_required=True,
|
||||
forms.LargeTextField(field_name="comment", maxlength=3000, is_required=True,
|
||||
validator_list=[self.hasNoProfanities]),
|
||||
)
|
||||
|
||||
|
@ -220,9 +221,9 @@ def post_comment(request):
|
|||
if manipulator.get_user() and new_data.has_key('password') and manipulator.get_user().check_password(new_data['password']):
|
||||
request.session[SESSION_KEY] = manipulator.get_user_id()
|
||||
if errors or request.POST.has_key('preview'):
|
||||
class CommentFormWrapper(formfields.FormWrapper):
|
||||
class CommentFormWrapper(forms.FormWrapper):
|
||||
def __init__(self, manipulator, new_data, errors, rating_choices):
|
||||
formfields.FormWrapper.__init__(self, manipulator, new_data, errors)
|
||||
forms.FormWrapper.__init__(self, manipulator, new_data, errors)
|
||||
self.rating_choices = rating_choices
|
||||
def ratings(self):
|
||||
field_list = [self['rating%d' % (i+1)] for i in range(len(rating_choices))]
|
||||
|
@ -301,7 +302,7 @@ def post_free_comment(request):
|
|||
comment = errors and '' or manipulator.get_comment(new_data)
|
||||
return render_to_response('comments/free_preview', {
|
||||
'comment': comment,
|
||||
'comment_form': formfields.FormWrapper(manipulator, new_data, errors),
|
||||
'comment_form': forms.FormWrapper(manipulator, new_data, errors),
|
||||
'options': options,
|
||||
'target': target,
|
||||
'hash': security_hash,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
from django.conf import settings
|
||||
from django.core import formfields, validators
|
||||
from django.core import validators
|
||||
|
||||
from django.db import backend, connection
|
||||
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
from django.db.models import signals
|
||||
from django.dispatch import dispatcher
|
||||
from django.conf import settings
|
||||
from django.core import formfields, validators
|
||||
from django.core import validators
|
||||
from django import forms
|
||||
from django.core.exceptions import ObjectDoesNotExist
|
||||
from django.utils.functional import curry, lazy
|
||||
from django.utils.text import capfirst
|
||||
|
@ -200,10 +201,10 @@ class Field(object):
|
|||
|
||||
if self.choices:
|
||||
if self.radio_admin:
|
||||
field_objs = [formfields.RadioSelectField]
|
||||
field_objs = [forms.RadioSelectField]
|
||||
params['ul_class'] = get_ul_class(self.radio_admin)
|
||||
else:
|
||||
field_objs = [formfields.SelectField]
|
||||
field_objs = [forms.SelectField]
|
||||
|
||||
params['choices'] = self.get_choices_default()
|
||||
else:
|
||||
|
@ -218,7 +219,7 @@ class Field(object):
|
|||
|
||||
def get_manipulator_fields(self, opts, manipulator, change, name_prefix='', rel=False, follow=True):
|
||||
"""
|
||||
Returns a list of formfields.FormField instances for this field. It
|
||||
Returns a list of forms.FormField instances for this field. It
|
||||
calculates the choices at runtime, not at compile time.
|
||||
|
||||
name_prefix is a prefix to prepend to the "field_name" argument.
|
||||
|
@ -333,7 +334,7 @@ class AutoField(Field):
|
|||
return Field.get_manipulator_fields(self, opts, manipulator, change, name_prefix, rel, follow)
|
||||
|
||||
def get_manipulator_field_objs(self):
|
||||
return [formfields.HiddenField]
|
||||
return [forms.HiddenField]
|
||||
|
||||
def get_manipulator_new_data(self, new_data, rel=False):
|
||||
# Never going to be called
|
||||
|
@ -355,15 +356,15 @@ class BooleanField(Field):
|
|||
Field.__init__(self, *args, **kwargs)
|
||||
|
||||
def get_manipulator_field_objs(self):
|
||||
return [formfields.CheckboxField]
|
||||
return [forms.CheckboxField]
|
||||
|
||||
class CharField(Field):
|
||||
def get_manipulator_field_objs(self):
|
||||
return [formfields.TextField]
|
||||
return [forms.TextField]
|
||||
|
||||
class CommaSeparatedIntegerField(CharField):
|
||||
def get_manipulator_field_objs(self):
|
||||
return [formfields.CommaSeparatedIntegerField]
|
||||
return [forms.CommaSeparatedIntegerField]
|
||||
|
||||
class DateField(Field):
|
||||
empty_strings_allowed = False
|
||||
|
@ -409,7 +410,7 @@ class DateField(Field):
|
|||
return Field.get_db_prep_save(self, value)
|
||||
|
||||
def get_manipulator_field_objs(self):
|
||||
return [formfields.DateField]
|
||||
return [forms.DateField]
|
||||
|
||||
def flatten_data(self, follow, obj = None):
|
||||
val = self._get_val_from_obj(obj)
|
||||
|
@ -427,7 +428,7 @@ class DateTimeField(DateField):
|
|||
return Field.get_db_prep_save(self, value)
|
||||
|
||||
def get_manipulator_field_objs(self):
|
||||
return [formfields.DateField, formfields.TimeField]
|
||||
return [forms.DateField, forms.TimeField]
|
||||
|
||||
def get_manipulator_field_names(self, name_prefix):
|
||||
return [name_prefix + self.name + '_date', name_prefix + self.name + '_time']
|
||||
|
@ -459,7 +460,7 @@ class EmailField(Field):
|
|||
return "CharField"
|
||||
|
||||
def get_manipulator_field_objs(self):
|
||||
return [formfields.EmailField]
|
||||
return [forms.EmailField]
|
||||
|
||||
class FileField(Field):
|
||||
def __init__(self, verbose_name=None, name=None, upload_to='', **kwargs):
|
||||
|
@ -524,7 +525,7 @@ class FileField(Field):
|
|||
os.remove(file_name)
|
||||
|
||||
def get_manipulator_field_objs(self):
|
||||
return [formfields.FileUploadField, formfields.HiddenField]
|
||||
return [forms.FileUploadField, forms.HiddenField]
|
||||
|
||||
def get_manipulator_field_names(self, name_prefix):
|
||||
return [name_prefix + self.name + '_file', name_prefix + self.name]
|
||||
|
@ -549,7 +550,7 @@ class FilePathField(Field):
|
|||
Field.__init__(self, verbose_name, name, **kwargs)
|
||||
|
||||
def get_manipulator_field_objs(self):
|
||||
return [curry(formfields.FilePathField, path=self.path, match=self.match, recursive=self.recursive)]
|
||||
return [curry(forms.FilePathField, path=self.path, match=self.match, recursive=self.recursive)]
|
||||
|
||||
class FloatField(Field):
|
||||
empty_strings_allowed = False
|
||||
|
@ -558,7 +559,7 @@ class FloatField(Field):
|
|||
Field.__init__(self, verbose_name, name, **kwargs)
|
||||
|
||||
def get_manipulator_field_objs(self):
|
||||
return [curry(formfields.FloatField, max_digits=self.max_digits, decimal_places=self.decimal_places)]
|
||||
return [curry(forms.FloatField, max_digits=self.max_digits, decimal_places=self.decimal_places)]
|
||||
|
||||
class ImageField(FileField):
|
||||
def __init__(self, verbose_name=None, name=None, width_field=None, height_field=None, **kwargs):
|
||||
|
@ -566,7 +567,7 @@ class ImageField(FileField):
|
|||
FileField.__init__(self, verbose_name, name, **kwargs)
|
||||
|
||||
def get_manipulator_field_objs(self):
|
||||
return [formfields.ImageUploadField, formfields.HiddenField]
|
||||
return [forms.ImageUploadField, forms.HiddenField]
|
||||
|
||||
def contribute_to_class(self, cls, name):
|
||||
super(ImageField, self).contribute_to_class(cls, name)
|
||||
|
@ -592,7 +593,7 @@ class ImageField(FileField):
|
|||
class IntegerField(Field):
|
||||
empty_strings_allowed = False
|
||||
def get_manipulator_field_objs(self):
|
||||
return [formfields.IntegerField]
|
||||
return [forms.IntegerField]
|
||||
|
||||
class IPAddressField(Field):
|
||||
def __init__(self, *args, **kwargs):
|
||||
|
@ -600,7 +601,7 @@ class IPAddressField(Field):
|
|||
Field.__init__(self, *args, **kwargs)
|
||||
|
||||
def get_manipulator_field_objs(self):
|
||||
return [formfields.IPAddressField]
|
||||
return [forms.IPAddressField]
|
||||
|
||||
class NullBooleanField(Field):
|
||||
def __init__(self, *args, **kwargs):
|
||||
|
@ -608,19 +609,19 @@ class NullBooleanField(Field):
|
|||
Field.__init__(self, *args, **kwargs)
|
||||
|
||||
def get_manipulator_field_objs(self):
|
||||
return [formfields.NullBooleanField]
|
||||
return [forms.NullBooleanField]
|
||||
|
||||
class PhoneNumberField(IntegerField):
|
||||
def get_manipulator_field_objs(self):
|
||||
return [formfields.PhoneNumberField]
|
||||
return [forms.PhoneNumberField]
|
||||
|
||||
class PositiveIntegerField(IntegerField):
|
||||
def get_manipulator_field_objs(self):
|
||||
return [formfields.PositiveIntegerField]
|
||||
return [forms.PositiveIntegerField]
|
||||
|
||||
class PositiveSmallIntegerField(IntegerField):
|
||||
def get_manipulator_field_objs(self):
|
||||
return [formfields.PositiveSmallIntegerField]
|
||||
return [forms.PositiveSmallIntegerField]
|
||||
|
||||
class SlugField(Field):
|
||||
def __init__(self, *args, **kwargs):
|
||||
|
@ -632,15 +633,15 @@ class SlugField(Field):
|
|||
Field.__init__(self, *args, **kwargs)
|
||||
|
||||
def get_manipulator_field_objs(self):
|
||||
return [formfields.TextField]
|
||||
return [forms.TextField]
|
||||
|
||||
class SmallIntegerField(IntegerField):
|
||||
def get_manipulator_field_objs(self):
|
||||
return [formfields.SmallIntegerField]
|
||||
return [forms.SmallIntegerField]
|
||||
|
||||
class TextField(Field):
|
||||
def get_manipulator_field_objs(self):
|
||||
return [formfields.LargeTextField]
|
||||
return [forms.LargeTextField]
|
||||
|
||||
class TimeField(Field):
|
||||
empty_strings_allowed = False
|
||||
|
@ -673,7 +674,7 @@ class TimeField(Field):
|
|||
return Field.get_db_prep_save(self, value)
|
||||
|
||||
def get_manipulator_field_objs(self):
|
||||
return [formfields.TimeField]
|
||||
return [forms.TimeField]
|
||||
|
||||
def flatten_data(self,follow, obj = None):
|
||||
val = self._get_val_from_obj(obj)
|
||||
|
@ -686,11 +687,11 @@ class URLField(Field):
|
|||
Field.__init__(self, verbose_name, name, **kwargs)
|
||||
|
||||
def get_manipulator_field_objs(self):
|
||||
return [formfields.URLField]
|
||||
return [forms.URLField]
|
||||
|
||||
class USStateField(Field):
|
||||
def get_manipulator_field_objs(self):
|
||||
return [formfields.USStateField]
|
||||
return [forms.USStateField]
|
||||
|
||||
class XMLField(TextField):
|
||||
def __init__(self, verbose_name=None, name=None, schema_path=None, **kwargs):
|
||||
|
@ -701,7 +702,7 @@ class XMLField(TextField):
|
|||
return "TextField"
|
||||
|
||||
def get_manipulator_field_objs(self):
|
||||
return [curry(formfields.XMLLargeTextField, schema_path=self.schema_path)]
|
||||
return [curry(forms.XMLLargeTextField, schema_path=self.schema_path)]
|
||||
|
||||
class OrderingField(IntegerField):
|
||||
empty_strings_allowed=False
|
||||
|
@ -714,7 +715,7 @@ class OrderingField(IntegerField):
|
|||
return "IntegerField"
|
||||
|
||||
def get_manipulator_fields(self, opts, manipulator, change, name_prefix='', rel=False, follow=True):
|
||||
return [formfields.HiddenField(name_prefix + self.name) ]
|
||||
return [forms.HiddenField(name_prefix + self.name) ]
|
||||
|
||||
def contribute_to_class(self, cls, name):
|
||||
super(OrderingField, self ).contribute_to_class(cls, name)
|
||||
|
|
|
@ -3,7 +3,8 @@ from django.db.models.fields import AutoField, Field, IntegerField
|
|||
from django.db.models.related import RelatedObject
|
||||
from django.utils.translation import gettext_lazy, string_concat
|
||||
from django.utils.functional import curry
|
||||
from django.core import formfields, validators
|
||||
from django.core import validators
|
||||
from django import forms
|
||||
from django.dispatch import dispatcher
|
||||
|
||||
# Values for Relation.edit_inline.
|
||||
|
@ -115,13 +116,13 @@ class ForeignKey(SharedMethods, Field):
|
|||
params['validator_list'].append(curry(manipulator_valid_rel_key, self, manipulator))
|
||||
else:
|
||||
if self.radio_admin:
|
||||
field_objs = [formfields.RadioSelectField]
|
||||
field_objs = [forms.RadioSelectField]
|
||||
params['ul_class'] = get_ul_class(self.radio_admin)
|
||||
else:
|
||||
if self.null:
|
||||
field_objs = [formfields.NullSelectField]
|
||||
field_objs = [forms.NullSelectField]
|
||||
else:
|
||||
field_objs = [formfields.SelectField]
|
||||
field_objs = [forms.SelectField]
|
||||
params['choices'] = self.get_choices_default()
|
||||
return (field_objs, params)
|
||||
|
||||
|
@ -130,7 +131,7 @@ class ForeignKey(SharedMethods, Field):
|
|||
if self.rel.raw_id_admin and not isinstance(rel_field, AutoField):
|
||||
return rel_field.get_manipulator_field_objs()
|
||||
else:
|
||||
return [formfields.IntegerField]
|
||||
return [forms.IntegerField]
|
||||
|
||||
def get_db_prep_save(self, value):
|
||||
if value == '' or value == None:
|
||||
|
@ -233,10 +234,10 @@ class ManyToManyField(RelatedField, Field):
|
|||
|
||||
def get_manipulator_field_objs(self):
|
||||
if self.rel.raw_id_admin:
|
||||
return [formfields.RawIdAdminField]
|
||||
return [forms.RawIdAdminField]
|
||||
else:
|
||||
choices = self.get_choices_default()
|
||||
return [curry(formfields.SelectMultipleField, size=min(max(len(choices), 5), 15), choices=choices)]
|
||||
return [curry(forms.SelectMultipleField, size=min(max(len(choices), 5), 15), choices=choices)]
|
||||
|
||||
def get_choices_default(self):
|
||||
return Field.get_choices(self, include_blank=False)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
from django.core.exceptions import ObjectDoesNotExist
|
||||
from django.core import formfields
|
||||
from django.core.formfields import Manipulator
|
||||
from django import forms
|
||||
from django.forms import Manipulator
|
||||
from django.db.models.fields import FileField, AutoField
|
||||
from django.db.models.exceptions import BadCommand
|
||||
from django.dispatch import dispatcher
|
||||
|
@ -497,7 +497,7 @@ def manipulator_validator_unique_together(field_name_list, opts, self, field_dat
|
|||
def manipulator_validator_unique_for_date(from_field, date_field, opts, lookup_type, self, field_data, all_data):
|
||||
from django.db.models.fields.related import ManyToOne
|
||||
date_str = all_data.get(date_field.get_manipulator_field_names('')[0], None)
|
||||
date_val = formfields.DateField.html2python(date_str)
|
||||
date_val = forms.DateField.html2python(date_str)
|
||||
if date_val is None:
|
||||
return # Date was invalid. This will be caught by another validator.
|
||||
lookup_kwargs = {'%s__year' % date_field.name: date_val.year}
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
from django.models.auth import User
|
||||
from django.core import formfields, validators
|
||||
from django.core import validators
|
||||
from django import forms
|
||||
|
||||
class AuthenticationForm(formfields.Manipulator):
|
||||
class AuthenticationForm(forms.Manipulator):
|
||||
"""
|
||||
Base class for authenticating users. Extend this to get a form that accepts
|
||||
username/password logins.
|
||||
|
@ -15,9 +16,9 @@ class AuthenticationForm(formfields.Manipulator):
|
|||
"""
|
||||
self.request = request
|
||||
self.fields = [
|
||||
formfields.TextField(field_name="username", length=15, maxlength=30, is_required=True,
|
||||
forms.TextField(field_name="username", length=15, maxlength=30, is_required=True,
|
||||
validator_list=[self.isValidUser, self.hasCookiesEnabled]),
|
||||
formfields.PasswordField(field_name="password", length=15, maxlength=30, is_required=True,
|
||||
forms.PasswordField(field_name="password", length=15, maxlength=30, is_required=True,
|
||||
validator_list=[self.isValidPasswordForUser]),
|
||||
]
|
||||
self.user_cache = None
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
from django.parts.auth.formfields import AuthenticationForm
|
||||
from django.core import formfields
|
||||
from django import forms
|
||||
from django.core.extensions import render_to_response
|
||||
from django.template import RequestContext
|
||||
from django.contrib.auth.models import SESSION_KEY
|
||||
|
@ -26,7 +26,7 @@ def login(request):
|
|||
errors = {}
|
||||
request.session.set_test_cookie()
|
||||
return render_to_response('registration/login', {
|
||||
'form': formfields.FormWrapper(manipulator, request.POST, errors),
|
||||
'form': forms.FormWrapper(manipulator, request.POST, errors),
|
||||
REDIRECT_FIELD_NAME: redirect_to,
|
||||
'site_name': Site.objects.get_current().name,
|
||||
}, context_instance=RequestContext(request))
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
from django.core.xheaders import populate_xheaders
|
||||
from django.template import loader
|
||||
from django.core import formfields, meta
|
||||
from django import forms
|
||||
from django.views.auth.login import redirect_to_login
|
||||
from django.template import RequestContext
|
||||
from django.core.paginator import ObjectPaginator, InvalidPage
|
||||
|
@ -54,7 +54,7 @@ def create_object(request, model, template_name=None,
|
|||
new_data = manipulator.flatten_data()
|
||||
|
||||
# Create the FormWrapper, template, context, response
|
||||
form = formfields.FormWrapper(manipulator, new_data, errors)
|
||||
form = forms.FormWrapper(manipulator, new_data, errors)
|
||||
if not template_name:
|
||||
template_name = "%s/%s_form" % (model._meta.app_label, model._meta.object_name.lower())
|
||||
t = template_loader.get_template(template_name)
|
||||
|
@ -123,7 +123,7 @@ def update_object(request, model, object_id=None, slug=None,
|
|||
# This makes sure the form acurate represents the fields of the place.
|
||||
new_data = manipulator.flatten_data()
|
||||
|
||||
form = formfields.FormWrapper(manipulator, new_data, errors)
|
||||
form = forms.FormWrapper(manipulator, new_data, errors)
|
||||
if not template_name:
|
||||
template_name = "%s/%s_form" % (model._meta.app_label, model._meta.object_name.lower())
|
||||
t = template_loader.get_template(template_name)
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
from django.core import formfields, validators
|
||||
from django import forms
|
||||
from django.core import validators
|
||||
from django.core.extensions import render_to_response
|
||||
from django.template import Context, RequestContext, loader
|
||||
from django.models.auth import User
|
||||
|
@ -6,11 +7,11 @@ from django.models.core import Site
|
|||
from django.views.decorators.auth import login_required
|
||||
from django.http import HttpResponseRedirect
|
||||
|
||||
class PasswordResetForm(formfields.Manipulator):
|
||||
class PasswordResetForm(forms.Manipulator):
|
||||
"A form that lets a user request a password reset"
|
||||
def __init__(self):
|
||||
self.fields = (
|
||||
formfields.EmailField(field_name="email", length=40, is_required=True,
|
||||
forms.EmailField(field_name="email", length=40, is_required=True,
|
||||
validator_list=[self.isValidUserEmail]),
|
||||
)
|
||||
|
||||
|
@ -43,16 +44,16 @@ class PasswordResetForm(formfields.Manipulator):
|
|||
}
|
||||
send_mail('Password reset on %s' % site_name, t.render(Context(c)), None, [self.user_cache.email])
|
||||
|
||||
class PasswordChangeForm(formfields.Manipulator):
|
||||
class PasswordChangeForm(forms.Manipulator):
|
||||
"A form that lets a user change his password."
|
||||
def __init__(self, user):
|
||||
self.user = user
|
||||
self.fields = (
|
||||
formfields.PasswordField(field_name="old_password", length=30, maxlength=30, is_required=True,
|
||||
forms.PasswordField(field_name="old_password", length=30, maxlength=30, is_required=True,
|
||||
validator_list=[self.isValidOldPassword]),
|
||||
formfields.PasswordField(field_name="new_password1", length=30, maxlength=30, is_required=True,
|
||||
forms.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.")]),
|
||||
formfields.PasswordField(field_name="new_password2", length=30, maxlength=30, is_required=True),
|
||||
forms.PasswordField(field_name="new_password2", length=30, maxlength=30, is_required=True),
|
||||
)
|
||||
|
||||
def isValidOldPassword(self, new_data, all_data):
|
||||
|
@ -77,7 +78,7 @@ def password_reset(request, is_admin_site=False):
|
|||
else:
|
||||
form.save()
|
||||
return HttpResponseRedirect('%sdone/' % request.path)
|
||||
return render_to_response('registration/password_reset_form', {'form': formfields.FormWrapper(form, new_data, errors)},
|
||||
return render_to_response('registration/password_reset_form', {'form': forms.FormWrapper(form, new_data, errors)},
|
||||
context_instance=RequestContext(request))
|
||||
|
||||
def password_reset_done(request):
|
||||
|
@ -92,7 +93,7 @@ def password_change(request):
|
|||
if not errors:
|
||||
form.save(new_data)
|
||||
return HttpResponseRedirect('%sdone/' % request.path)
|
||||
return render_to_response('registration/password_change_form', {'form': formfields.FormWrapper(form, new_data, errors)},
|
||||
return render_to_response('registration/password_change_form', {'form': forms.FormWrapper(form, new_data, errors)},
|
||||
context_instance=RequestContext(request))
|
||||
password_change = login_required(password_change)
|
||||
|
||||
|
|
Loading…
Reference in New Issue