Ticket #18102: Django-1.3.1_localflavor_forms.patch

File Django-1.3.1_localflavor_forms.patch, 1.5 KB (added by mothsART, 3 years ago)
  • django/contrib/localflavor/fr/forms.py

    FR-specific Form helpers 
    44
    55from django.core.validators import EMPTY_VALUES
    66from django.forms import ValidationError
    7 from django.forms.fields import Field, RegexField, Select
     7from django.forms.fields import CharField, RegexField, Select
    88from django.utils.encoding import smart_unicode
    99from django.utils.translation import ugettext_lazy as _
    1010import re
    class FRZipCodeField(RegexField): 
    1818
    1919    def __init__(self, *args, **kwargs):
    2020        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)
    2222
    23 class FRPhoneNumberField(Field):
     23class FRPhoneNumberField(CharField):
    2424    """
    2525    Validate local French phone number (not international ones)
    2626    The correct format is '0X XX XX XX XX'.
    class FRPhoneNumberField(Field): 
    3131        'invalid': _('Phone numbers must be in 0X XX XX XX XX format.'),
    3232    }
    3333
     34    def __init__(self, *args, **kwargs):
     35        super(FRPhoneNumberField, self).__init__(
     36            max_length=14, min_length=10, *args, **kwargs)
     37
    3438    def clean(self, value):
    3539        super(FRPhoneNumberField, self).clean(value)
    3640        if value in EMPTY_VALUES:
    class FRDepartmentSelect(Select): 
    4852    def __init__(self, attrs=None):
    4953        from fr_department import DEPARTMENT_ASCII_CHOICES
    5054        super(FRDepartmentSelect, self).__init__(attrs, choices=DEPARTMENT_ASCII_CHOICES)
    51 
Back to Top