Ticket #18102: Django-1.3.1_localflavor_forms.patch
File Django-1.3.1_localflavor_forms.patch, 1.5 KB (added by , 13 years ago) |
---|
-
django/contrib/localflavor/fr/forms.py
FR-specific Form helpers 4 4 5 5 from django.core.validators import EMPTY_VALUES 6 6 from django.forms import ValidationError 7 from django.forms.fields import Field, RegexField, Select7 from django.forms.fields import CharField, RegexField, Select 8 8 from django.utils.encoding import smart_unicode 9 9 from django.utils.translation import ugettext_lazy as _ 10 10 import re … … class FRZipCodeField(RegexField): 18 18 19 19 def __init__(self, *args, **kwargs): 20 20 super(FRZipCodeField, self).__init__(r'^\d{5}$', 21 max_length= None, min_length=None, *args, **kwargs)21 max_length=5, min_length=5, *args, **kwargs) 22 22 23 class FRPhoneNumberField( Field):23 class FRPhoneNumberField(CharField): 24 24 """ 25 25 Validate local French phone number (not international ones) 26 26 The correct format is '0X XX XX XX XX'. … … class FRPhoneNumberField(Field): 31 31 'invalid': _('Phone numbers must be in 0X XX XX XX XX format.'), 32 32 } 33 33 34 def __init__(self, *args, **kwargs): 35 super(FRPhoneNumberField, self).__init__( 36 max_length=14, min_length=10, *args, **kwargs) 37 34 38 def clean(self, value): 35 39 super(FRPhoneNumberField, self).clean(value) 36 40 if value in EMPTY_VALUES: … … class FRDepartmentSelect(Select): 48 52 def __init__(self, attrs=None): 49 53 from fr_department import DEPARTMENT_ASCII_CHOICES 50 54 super(FRDepartmentSelect, self).__init__(attrs, choices=DEPARTMENT_ASCII_CHOICES) 51