Ticket #6637: 6637.diff
File 6637.diff, 3.7 KB (added by , 17 years ago) |
---|
-
django/oldforms/__init__.py
972 972 973 973 class PhoneNumberField(TextField): 974 974 "A convenience FormField for validating phone numbers (e.g. '630-555-1234')" 975 def __init__(self, field_name, is_required=False, validator_list=None):975 def __init__(self, field_name, max_length=None, is_required=False, validator_list=None): 976 976 if validator_list is None: validator_list = [] 977 977 validator_list = [self.isValidPhone] + validator_list 978 978 TextField.__init__(self, field_name, length=12, max_length=12, -
django/db/models/fields/__init__.py
967 967 defaults.update(kwargs) 968 968 return super(NullBooleanField, self).formfield(**defaults) 969 969 970 class PhoneNumberField(IntegerField): 970 class PhoneNumberField(CharField): 971 972 def __init__(self, *args, **kwargs): 973 kwargs['max_length'] = kwargs.get('max_length', 15) 974 CharField.__init__(self, *args, **kwargs) 975 971 976 def get_manipulator_field_objs(self): 972 977 return [oldforms.PhoneNumberField] 973 978 … … 981 986 from django.contrib.localflavor.us.forms import USPhoneNumberField 982 987 defaults = {'form_class': USPhoneNumberField} 983 988 defaults.update(kwargs) 984 return super( PhoneNumberField, self).formfield(**defaults)989 return super(CharField, self).formfield(**defaults) 985 990 986 991 class PositiveIntegerField(IntegerField): 987 992 def get_manipulator_field_objs(self): -
django/contrib/localflavor/us/forms.py
35 35 return u'%s-%s-%s' % (m.group(1), m.group(2), m.group(3)) 36 36 raise ValidationError(self.error_messages['invalid']) 37 37 38 def __init__(self, *args, **kwargs): 39 super(USPhoneNumberField, self).__init__(*args, **kwargs) 40 38 41 class USSocialSecurityNumberField(Field): 39 42 """ 40 43 A United States Social Security number. -
tests/regressiontests/model_fields/tests.py
1 """ 1 from django.db import models 2 3 class PhoneNumber(models.Model): 4 phone = models.PhoneNumberField(null=False, blank=True) 5 description = models.CharField(max_length=20) 6 7 def __unicode__(self): 8 return self.phone 9 10 __test__ = {'API_TESTS': """ 2 11 >>> from django.db.models.fields import * 3 12 4 13 # DecimalField … … 15 24 Traceback (most recent call last): 16 25 ... 17 26 ValidationError: [u'This value must be a decimal number.'] 18 """ 27 28 # Make sure that a blank phone number can be saved. 29 # See http://code.djangoproject.com/ticket/6637 30 >>> p = PhoneNumber() 31 >>> p.save() 32 >>> PhoneNumber.objects.all() 33 [<PhoneNumber: >] 34 >>> p = PhoneNumber() 35 >>> p.phone = "612-282-2573" 36 >>> p.description = "Fake Phone Number" 37 >>> p.save() 38 >>> PhoneNumber.objects.all() 39 [<PhoneNumber: >, <PhoneNumber: 612-282-2573>] 40 """} -
AUTHORS
377 377 ymasuda@ethercube.com 378 378 Jarek Zgoda <jarek.zgoda@gmail.com> 379 379 Cheng Zhang 380 Curtis Thompson <curtis.thompson@gmail.com> 380 381 381 382 A big THANK YOU goes to: 382 383