Ticket #4036: 4036_3.diff

File 4036_3.diff, 23.8 KB (added by Marc Garcia, 17 years ago)

spanish localflavor files

  • django/contrib/localflavor/es/es_regions.py

     
     1# -*- coding: utf-8 -*-
     2from django.utils.translation import ugettext_lazy as _
     3
     4REGION_CHOICES = (
     5        ('AN', _('Andalusia')),
     6        ('AR', _('Aragon')),
     7        ('O', _('Principality of Asturias')),
     8        ('IB', _('Balearic Islands')),
     9        ('PV', _('Basque Country')),
     10        ('CN', _('Canary Islands')),
     11        ('S', _('Cantabria')),
     12        ('CM', _('Castile-La Mancha')),
     13        ('CL', _('Castile and Leon')),
     14        ('CT', _('Catalonia')),
     15        ('EX', _('Extremadura')),
     16        ('GA', _('Galicia')),
     17        ('LO', _('La Rioja')),
     18        ('M', _('Madrid')),
     19        ('MU', _('Region of Murcia')),
     20        ('NA', _('Foral Community of Navarre')),
     21        ('VC', _('Valencian Community')),
     22)
     23
  • django/contrib/localflavor/es/es_provinces.py

     
     1# -*- coding: utf-8 -*-
     2from django.utils.translation import ugettext_lazy as _
     3
     4PROVINCE_CHOICES = (
     5        ('01', _('Arava')),
     6        ('02', _('Albacete')),
     7        ('03', _('Alacant')),
     8        ('04', _('Almeria')),
     9        ('05', _('Avila')),
     10        ('06', _('Badajoz')),
     11        ('07', _('Illes Balears')),
     12        ('08', _('Barcelona')),
     13        ('09', _('Burgos')),
     14        ('10', _('Caceres')),
     15        ('11', _('Cadiz')),
     16        ('12', _('Castello')),
     17        ('13', _('Ciudad Real')),
     18        ('14', _('Cordoba')),
     19        ('15', _('A Coruna')),
     20        ('16', _('Cuenca')),
     21        ('17', _('Girona')),
     22        ('18', _('Granada')),
     23        ('19', _('Guadalajara')),
     24        ('20', _('Guipuzkoa')),
     25        ('21', _('Huelva')),
     26        ('22', _('Huesca')),
     27        ('23', _('Jaen')),
     28        ('24', _('Leon')),
     29        ('25', _('Lleida')),
     30        ('26', _('La Rioja')),
     31        ('27', _('Lugo')),
     32        ('28', _('Madrid')),
     33        ('29', _('Malaga')),
     34        ('30', _('Murcia')),
     35        ('31', _('Navarre')),
     36        ('32', _('Ourense')),
     37        ('33', _('Asturias')),
     38        ('34', _('Palencia')),
     39        ('35', _('Las Palmas')),
     40        ('36', _('Pontevedra')),
     41        ('37', _('Salamanca')),
     42        ('38', _('Santa Cruz de Tenerife')),
     43        ('39', _('Cantabria')),
     44        ('40', _('Segovia')),
     45        ('41', _('Seville')),
     46        ('42', _('Soria')),
     47        ('43', _('Tarragona')),
     48        ('44', _('Teruel')),
     49        ('45', _('Toledo')),
     50        ('46', _('Valencia')),
     51        ('47', _('Valladolid')),
     52        ('48', _('Bizkaia')),
     53        ('49', _('Zamora')),
     54        ('50', _('Zaragoza')),
     55        ('51', _('Ceuta')),
     56        ('52', _('Melilla')),
     57)
     58
  • django/contrib/localflavor/es/forms.py

     
     1# -*- coding: utf-8 -*-
     2"""
     3Spanish-specific Form helpers
     4"""
     5
     6from django.newforms import ValidationError
     7from django.newforms.fields import RegexField, Select, EMPTY_VALUES
     8from django.utils.translation import ugettext as _
     9import re
     10
     11class ESPostalCodeField(RegexField):
     12    """
     13    A form field that validates its input as a spanish postal code.
     14   
     15    Spanish postal code is a five digits string, with two first digits
     16    between 01 and 52, assigned to provinces code.
     17    """
     18    def __init__(self, *args, **kwargs):
     19        super(ESPostalCodeField, self).__init__(r'^(0[1-9]|[1-4][0-9]|5[0-2])\d{3}$',
     20            max_length=None, min_length=None,
     21            error_message=_('Enter a valid postal code in the range and format 01XXX - 52XXX.'),
     22            *args, **kwargs)
     23
     24class ESPhoneNumberField(RegexField):
     25        """
     26        A form field that validates its input as a spanish Phone Number. Information numbers are ommited.
     27
     28        Spanish phone numbers are 9 digit numbers, where first digit is 6 (for cell phones), 8 (for special
     29        phones), or 9 (for landlines and special phones)
     30
     31        TODO: accept and strip characters like dot, hyphen... in phone number
     32        """
     33        def __init__(self, *args, **kwargs):
     34                super(ESPhoneNumberField, self).__init__(r'^(6|8|9)\d{8}$',
     35                                max_length=None, min_length=None,
     36                                error_message=_('Enter a valid phone number in one of the formats 6XXXXXXXX, 8XXXXXXXX or 9XXXXXXXX.'),
     37                                *args, **kwargs)
     38
     39class ESIdentityCardNumberField(RegexField):
     40        """
     41        Spanish NIF/NIE/CIF (Fiscal Identification Number) code.
     42
     43        Validates three diferent formats,
     44                NIF (individuals): 12345678A
     45                CIF (companies): A12345678
     46                NIE (foreigners): X12345678A
     47        according to a couple of simple checksum algorithms.
     48        Value can include a space or hyphen separator between number and letters.
     49        Number length is not checked for nif (or nie), old values started by 1, and future values can be more than 8.
     50        CIF control digit can be a number or a letter depending on company type. Algorithm is not public, and different
     51        authors have different opinions on which ones allows letters, so both validations are assumed true for all types.
     52        """
     53        def __init__(self, only_nif=False, *args, **kwargs):
     54                self.only_nif = only_nif
     55                self.nif_control = 'TRWAGMYFPDXBNJZSQVHLCKE'
     56                self.cif_control = 'JABCDEFGHI'
     57                self.cif_types = 'ABCDEFGHKLMNPQS'
     58                self.nie_types = 'XT'
     59                if self.only_nif:
     60                        self.id_types = 'NIF or NIE'
     61                else:
     62                        self.id_types = 'NIF, NIE, or CIF'
     63                super(ESIdentityCardNumberField, self).__init__(r'^([%s]?)[ -]?(\d+)[ -]?([%s]?)$' % (self.cif_types + self.nie_types + self.cif_types.lower() + self.nie_types.lower(), self.nif_control + self.nif_control.lower()),
     64                                max_length=None, min_length=None,
     65                                error_message=_('Please enter a valid %s.' % self.id_types),
     66                                *args, **kwargs)
     67
     68        def clean(self, value):
     69                super(ESIdentityCardNumberField, self).clean(value)       
     70                if value in EMPTY_VALUES:
     71                        return u''
     72                nif_get_checksum = lambda d: self.nif_control[int(d)%23]
     73                def cif_get_checksum(number):
     74                        s1 = sum([int(digit) for pos, digit in enumerate(number) if int(pos) % 2])
     75                        s2 = sum([sum([int(unit) for unit in str(int(digit) * 2)]) for pos, digit in enumerate(number) if not int(pos) % 2])
     76                        return 10 - ((s1 + s2) % 10)
     77
     78                value = value.upper().replace(' ', '').replace('-', '')
     79                m = re.match(r'^([%s]?)[ -]?(\d+)[ -]?([%s]?)$' % (self.cif_types + self.nie_types, self.nif_control), value)
     80                letter1, number, letter2 = m.groups()
     81
     82                if not letter1 and letter2: # NIF
     83                        if letter2 == nif_get_checksum(number):
     84                                return value
     85                        else:
     86                                raise ValidationError, _('Invalid checksum for NIF.')
     87                elif letter1 in self.nie_types and letter2: # NIE
     88                        if letter2 == nif_get_checksum(number):
     89                                return value
     90                        else:
     91                                raise ValidationError, _('Invalid checksum for NIE.')
     92                elif not self.only_nif and letter1 in self.cif_types and len(number) in [7, 8]: # CIF
     93                        if not letter2:
     94                                number, letter2 = number[:-1], int(number[-1])
     95                        checksum = cif_get_checksum(number)
     96                        if letter2 in [checksum, self.cif_control[checksum]]:
     97                                return value
     98                        else:
     99                                raise ValidationError, _('Invalid checksum for CIF.')
     100                else:
     101                        raise ValidationError, _('Please enter a valid %s.' % self.id_types)
     102
     103class ESCCCField(RegexField):
     104        """
     105    A form field that validates its input as a spanish bank account or CCC (Codigo Cuenta Cliente)
     106
     107                Spanish CCC is in format EEEE-OOOO-CC-AAAAAAAAAA where
     108                        E = entity
     109                        O = office
     110                        C = checksum
     111                        A = account
     112                It's also valid using space as delimiter, or using no delimiter
     113
     114                First checksum digit validates entity and office, and last one validates account. Validation is
     115                done multiplying every digit of 10 digit value (with leading 0 if necessary) by number in its
     116                position in string 1, 2, 4, 8, 5, 10, 9, 7, 3, 6. Sum resulting numbers and extract it from 11.
     117                Result is checksum except when 10 then is 1, or when 11 then is 0.
     118
     119                TODO: allow IBAN validation too
     120        """
     121        def __init__(self, nif=True, cif=True, *args, **kwargs):
     122                super(ESCCCField, self).__init__(r'^\d{4}[ -]?\d{4}[ -]?\d{2}[ -]?\d{10}$',
     123                        max_length=None, min_length=None,
     124                        error_message=_('Please enter a valid bank account number in format XXXX-XXXX-XX-XXXXXXXXXX.'),
     125                        *args, **kwargs)
     126        def clean(self, value):
     127                super(ESCCCField, self).clean(value)       
     128                if value in EMPTY_VALUES:
     129                        return u''
     130                control_str = [1, 2, 4, 8, 5, 10, 9, 7, 3, 6]
     131                m = re.match(r'^(\d{4})[ -]?(\d{4})[ -]?(\d{2})[ -]?(\d{10})$', value)
     132                entity, office, checksum, account = m.groups()
     133                get_checksum = lambda d: str(11 - sum([int(digit) * int(control) for digit, control in zip(d, control_str)]) % 11).replace('10', '1').replace('11', '0')
     134                if get_checksum('00' + entity + office) + get_checksum(account) == checksum:
     135                        return value
     136                else:
     137                        raise ValidationError, _('Invalid checksum for bank account number.')
     138
     139class ESRegionSelect(Select):
     140    """
     141    A Select widget that uses a list of spanish regions as its choices.
     142    """
     143    def __init__(self, attrs=None):
     144        from es_regions import REGION_CHOICES
     145        super(ESRegionSelect, self).__init__(attrs, choices=REGION_CHOICES)
     146
     147class ESProvinceSelect(Select):
     148    """
     149    A Select widget that uses a list of spanish provinces as its choices.
     150    """
     151    def __init__(self, attrs=None):
     152        from es_provinces import PROVINCE_CHOICES
     153        super(ESProvinceSelect, self).__init__(attrs, choices=PROVINCE_CHOICES)
     154
  • tests/regressiontests/forms/localflavor/es.py

     
     1# -*- coding: utf-8 -*-
     2# Tests for the contrib/localflavor/ ES form fields.
     3
     4tests = r"""
     5# ESPostalCodeField ##############################################################
     6
     7ESPostalCodeField validates that data is a five-digit spanish postal code.
     8>>> from django.contrib.localflavor.es.forms import ESPostalCodeField
     9>>> f = ESPostalCodeField()
     10>>> f.clean('08028')
     11u'08028'
     12>>> f.clean('28080')
     13u'28080'
     14>>> f.clean('53001')
     15Traceback (most recent call last):
     16...
     17ValidationError: [u'Enter a valid postal code in the range and format 01XXX - 52XXX.']
     18>>> f.clean('0801')
     19Traceback (most recent call last):
     20...
     21ValidationError: [u'Enter a valid postal code in the range and format 01XXX - 52XXX.']
     22>>> f.clean('080001')
     23Traceback (most recent call last):
     24...
     25ValidationError: [u'Enter a valid postal code in the range and format 01XXX - 52XXX.']
     26>>> f.clean('00999')
     27Traceback (most recent call last):
     28...
     29ValidationError: [u'Enter a valid postal code in the range and format 01XXX - 52XXX.']
     30>>> f.clean('08 01')
     31Traceback (most recent call last):
     32...
     33ValidationError: [u'Enter a valid postal code in the range and format 01XXX - 52XXX.']
     34>>> f.clean('08A01')
     35Traceback (most recent call last):
     36...
     37ValidationError: [u'Enter a valid postal code in the range and format 01XXX - 52XXX.']
     38>>> f.clean('')
     39Traceback (most recent call last):
     40...
     41ValidationError: [u'This field is required.']
     42
     43>>> f = ESPostalCodeField(required=False)
     44>>> f.clean('08028')
     45u'08028'
     46>>> f.clean('28080')
     47u'28080'
     48>>> f.clean('53001')
     49Traceback (most recent call last):
     50...
     51ValidationError: [u'Enter a valid postal code in the range and format 01XXX - 52XXX.']
     52>>> f.clean('0801')
     53Traceback (most recent call last):
     54...
     55ValidationError: [u'Enter a valid postal code in the range and format 01XXX - 52XXX.']
     56>>> f.clean('080001')
     57Traceback (most recent call last):
     58...
     59ValidationError: [u'Enter a valid postal code in the range and format 01XXX - 52XXX.']
     60>>> f.clean('00999')
     61Traceback (most recent call last):
     62...
     63ValidationError: [u'Enter a valid postal code in the range and format 01XXX - 52XXX.']
     64>>> f.clean('08 01')
     65Traceback (most recent call last):
     66...
     67ValidationError: [u'Enter a valid postal code in the range and format 01XXX - 52XXX.']
     68>>> f.clean('08A01')
     69Traceback (most recent call last):
     70...
     71ValidationError: [u'Enter a valid postal code in the range and format 01XXX - 52XXX.']
     72>>> f.clean('')
     73u''
     74
     75# ESPhoneNumberField ##############################################################
     76
     77ESPhoneNumberField validates that data is a nine-digit spanish phone number.
     78>>> from django.contrib.localflavor.es.forms import ESPhoneNumberField
     79>>> f = ESPhoneNumberField()
     80>>> f.clean('650010101')
     81u'650010101'
     82>>> f.clean('931234567')
     83u'931234567'
     84>>> f.clean('800123123')
     85u'800123123'
     86>>> f.clean('555555555')
     87Traceback (most recent call last):
     88...
     89ValidationError: [u'Enter a valid phone number in one of the formats 6XXXXXXXX, 8XXXXXXXX or 9XXXXXXXX.']
     90>>> f.clean('789789789')
     91Traceback (most recent call last):
     92...
     93ValidationError: [u'Enter a valid phone number in one of the formats 6XXXXXXXX, 8XXXXXXXX or 9XXXXXXXX.']
     94>>> f.clean('99123123')
     95Traceback (most recent call last):
     96...
     97ValidationError: [u'Enter a valid phone number in one of the formats 6XXXXXXXX, 8XXXXXXXX or 9XXXXXXXX.']
     98>>> f.clean('9999123123')
     99Traceback (most recent call last):
     100...
     101ValidationError: [u'Enter a valid phone number in one of the formats 6XXXXXXXX, 8XXXXXXXX or 9XXXXXXXX.']
     102>>> f.clean('')
     103Traceback (most recent call last):
     104...
     105ValidationError: [u'This field is required.']
     106
     107>>> f = ESPhoneNumberField(required=False)
     108>>> f.clean('650010101')
     109u'650010101'
     110>>> f.clean('931234567')
     111u'931234567'
     112>>> f.clean('800123123')
     113u'800123123'
     114>>> f.clean('555555555')
     115Traceback (most recent call last):
     116...
     117ValidationError: [u'Enter a valid phone number in one of the formats 6XXXXXXXX, 8XXXXXXXX or 9XXXXXXXX.']
     118>>> f.clean('789789789')
     119Traceback (most recent call last):
     120...
     121ValidationError: [u'Enter a valid phone number in one of the formats 6XXXXXXXX, 8XXXXXXXX or 9XXXXXXXX.']
     122>>> f.clean('99123123')
     123Traceback (most recent call last):
     124...
     125ValidationError: [u'Enter a valid phone number in one of the formats 6XXXXXXXX, 8XXXXXXXX or 9XXXXXXXX.']
     126>>> f.clean('9999123123')
     127Traceback (most recent call last):
     128...
     129ValidationError: [u'Enter a valid phone number in one of the formats 6XXXXXXXX, 8XXXXXXXX or 9XXXXXXXX.']
     130>>> f.clean('')
     131u''
     132
     133# ESIdentityCardNumberField ##############################################################
     134
     135ESIdentityCardNumberField validates that data is a identification spanish code for companies or individuals (CIF, NIF or NIE).
     136>>> from django.contrib.localflavor.es.forms import ESIdentityCardNumberField
     137>>> f = ESIdentityCardNumberField()
     138>>> f.clean('78699688J')
     139'78699688J'
     140>>> f.clean('78699688-J')
     141'78699688J'
     142>>> f.clean('78699688 J')
     143'78699688J'
     144>>> f.clean('78699688 j')
     145'78699688J'
     146>>> f.clean('78699688T')
     147Traceback (most recent call last):
     148...
     149ValidationError: [u'Invalid checksum for NIF.']
     150>>> f.clean('X0901797J')
     151'X0901797J'
     152>>> f.clean('X-6124387-Q')
     153'X6124387Q'
     154>>> f.clean('X 0012953 G')
     155'X0012953G'
     156>>> f.clean('x-3287690-r')
     157'X3287690R'
     158>>> f.clean('t-03287690r')
     159'T03287690R'
     160>>> f.clean('X-03287690')
     161Traceback (most recent call last):
     162...
     163ValidationError: [u'Please enter a valid NIF, NIE, or CIF.']
     164>>> f.clean('X-03287690-T')
     165Traceback (most recent call last):
     166...
     167ValidationError: [u'Invalid checksum for NIE.']
     168>>> f.clean('B38790911')
     169'B38790911'
     170>>> f.clean('B-3879091A')
     171'B3879091A'
     172>>> f.clean('B 38790917')
     173Traceback (most recent call last):
     174...
     175ValidationError: [u'Invalid checksum for CIF.']
     176>>> f.clean('B 38790911')
     177'B38790911'
     178>>> f.clean('P-3900800-H')
     179'P3900800H'
     180>>> f.clean('P 39008008')
     181'P39008008'
     182>>> f.clean('C-28795565')
     183'C28795565'
     184>>> f.clean('C 2879556E')
     185'C2879556E'
     186>>> f.clean('C28795567')
     187Traceback (most recent call last):
     188...
     189ValidationError: [u'Invalid checksum for CIF.']
     190>>> f.clean('I38790911')
     191Traceback (most recent call last):
     192...
     193ValidationError: [u'Please enter a valid NIF, NIE, or CIF.']
     194>>> f.clean('78699688-2')
     195Traceback (most recent call last):
     196...
     197ValidationError: [u'Please enter a valid NIF, NIE, or CIF.']
     198>>> f.clean('')
     199Traceback (most recent call last):
     200...
     201ValidationError: [u'This field is required.']
     202
     203>>> f = ESIdentityCardNumberField(required=False)
     204>>> f.clean('78699688J')
     205'78699688J'
     206>>> f.clean('78699688-J')
     207'78699688J'
     208>>> f.clean('78699688 J')
     209'78699688J'
     210>>> f.clean('78699688 j')
     211'78699688J'
     212>>> f.clean('78699688T')
     213Traceback (most recent call last):
     214...
     215ValidationError: [u'Invalid checksum for NIF.']
     216>>> f.clean('X0901797J')
     217'X0901797J'
     218>>> f.clean('X-6124387-Q')
     219'X6124387Q'
     220>>> f.clean('X 0012953 G')
     221'X0012953G'
     222>>> f.clean('x-3287690-r')
     223'X3287690R'
     224>>> f.clean('t-03287690r')
     225'T03287690R'
     226>>> f.clean('X-03287690')
     227Traceback (most recent call last):
     228...
     229ValidationError: [u'Please enter a valid NIF, NIE, or CIF.']
     230>>> f.clean('X-03287690-T')
     231Traceback (most recent call last):
     232...
     233ValidationError: [u'Invalid checksum for NIE.']
     234>>> f.clean('B38790911')
     235'B38790911'
     236>>> f.clean('B-3879091A')
     237'B3879091A'
     238>>> f.clean('B 38790917')
     239Traceback (most recent call last):
     240...
     241ValidationError: [u'Invalid checksum for CIF.']
     242>>> f.clean('B 38790911')
     243'B38790911'
     244>>> f.clean('P-3900800-H')
     245'P3900800H'
     246>>> f.clean('P 39008008')
     247'P39008008'
     248>>> f.clean('C-28795565')
     249'C28795565'
     250>>> f.clean('C 2879556E')
     251'C2879556E'
     252>>> f.clean('C28795567')
     253Traceback (most recent call last):
     254...
     255ValidationError: [u'Invalid checksum for CIF.']
     256>>> f.clean('I38790911')
     257Traceback (most recent call last):
     258...
     259ValidationError: [u'Please enter a valid NIF, NIE, or CIF.']
     260>>> f.clean('78699688-2')
     261Traceback (most recent call last):
     262...
     263ValidationError: [u'Please enter a valid NIF, NIE, or CIF.']
     264>>> f.clean('')
     265u''
     266
     267# ESCCCField ##############################################################
     268
     269ESCCCField validates that data is a spanish bank account number (codigo cuenta cliente).
     270
     271>>> from django.contrib.localflavor.es.forms import ESCCCField
     272>>> f = ESCCCField()
     273>>> f.clean('20770338793100254321')
     274'20770338793100254321'
     275>>> f.clean('2077 0338 79 3100254321')
     276'2077 0338 79 3100254321'
     277>>> f.clean('2077-0338-79-3100254321')
     278'2077-0338-79-3100254321'
     279>>> f.clean('2077.0338.79.3100254321')
     280Traceback (most recent call last):
     281...
     282ValidationError: [u'Please enter a valid bank account number in format XXXX-XXXX-XX-XXXXXXXXXX.']
     283>>> f.clean('2077-0338-78-3100254321')
     284Traceback (most recent call last):
     285...
     286ValidationError: [u'Invalid checksum for bank account number.']
     287>>> f.clean('2077-0338-89-3100254321')
     288Traceback (most recent call last):
     289...
     290ValidationError: [u'Invalid checksum for bank account number.']
     291>>> f.clean('2077-03-3879-3100254321')
     292Traceback (most recent call last):
     293...
     294ValidationError: [u'Please enter a valid bank account number in format XXXX-XXXX-XX-XXXXXXXXXX.']
     295>>> f.clean('')
     296Traceback (most recent call last):
     297...
     298ValidationError: [u'This field is required.']
     299
     300>>> f = ESCCCField(required=False)
     301>>> f.clean('20770338793100254321')
     302'20770338793100254321'
     303>>> f.clean('2077 0338 79 3100254321')
     304'2077 0338 79 3100254321'
     305>>> f.clean('2077-0338-79-3100254321')
     306'2077-0338-79-3100254321'
     307>>> f.clean('2077.0338.79.3100254321')
     308Traceback (most recent call last):
     309...
     310ValidationError: [u'Please enter a valid bank account number in format XXXX-XXXX-XX-XXXXXXXXXX.']
     311>>> f.clean('2077-0338-78-3100254321')
     312Traceback (most recent call last):
     313...
     314ValidationError: [u'Invalid checksum for bank account number.']
     315>>> f.clean('2077-0338-89-3100254321')
     316Traceback (most recent call last):
     317...
     318ValidationError: [u'Invalid checksum for bank account number.']
     319>>> f.clean('2077-03-3879-3100254321')
     320Traceback (most recent call last):
     321...
     322ValidationError: [u'Please enter a valid bank account number in format XXXX-XXXX-XX-XXXXXXXXXX.']
     323>>> f.clean('')
     324u''
     325
     326# ESRegionSelect ##############################################################
     327
     328ESRegionSelect is a Select widget that uses a list of Spain regions as its choices.
     329>>> from django.contrib.localflavor.es.forms import ESRegionSelect
     330>>> w = ESRegionSelect()
     331>>> w.render('regions', 'CT')
     332u'<select name="regions">\n<option value="AN">Andalusia</option>\n<option value="AR">Aragon</option>\n<option value="O">Principality of Asturias</option>\n<option value="IB">Balearic Islands</option>\n<option value="PV">Basque Country</option>\n<option value="CN">Canary Islands</option>\n<option value="S">Cantabria</option>\n<option value="CM">Castile-La Mancha</option>\n<option value="CL">Castile and Leon</option>\n<option value="CT" selected="selected">Catalonia</option>\n<option value="EX">Extremadura</option>\n<option value="GA">Galicia</option>\n<option value="LO">La Rioja</option>\n<option value="M">Madrid</option>\n<option value="MU">Region of Murcia</option>\n<option value="NA">Foral Community of Navarre</option>\n<option value="VC">Valencian Community</option>\n</select>'
     333
     334# ESProvincenSelect ##############################################################
     335
     336ESProvinceSelect is a Select widget that uses a list of Spain provinces as its choices.
     337>>> from django.contrib.localflavor.es.forms import ESProvinceSelect
     338>>> w = ESProvinceSelect()
     339>>> w.render('provinces', '08')
     340u'<select name="provinces">\n<option value="01">Arava</option>\n<option value="02">Albacete</option>\n<option value="03">Alacant</option>\n<option value="04">Almeria</option>\n<option value="05">Avila</option>\n<option value="06">Badajoz</option>\n<option value="07">Illes Balears</option>\n<option value="08" selected="selected">Barcelona</option>\n<option value="09">Burgos</option>\n<option value="10">Caceres</option>\n<option value="11">Cadiz</option>\n<option value="12">Castello</option>\n<option value="13">Ciudad Real</option>\n<option value="14">Cordoba</option>\n<option value="15">A Coruna</option>\n<option value="16">Cuenca</option>\n<option value="17">Girona</option>\n<option value="18">Granada</option>\n<option value="19">Guadalajara</option>\n<option value="20">Guipuzkoa</option>\n<option value="21">Huelva</option>\n<option value="22">Huesca</option>\n<option value="23">Jaen</option>\n<option value="24">Leon</option>\n<option value="25">Lleida</option>\n<option value="26">La Rioja</option>\n<option value="27">Lugo</option>\n<option value="28">Madrid</option>\n<option value="29">Malaga</option>\n<option value="30">Murcia</option>\n<option value="31">Navarre</option>\n<option value="32">Ourense</option>\n<option value="33">Asturias</option>\n<option value="34">Palencia</option>\n<option value="35">Las Palmas</option>\n<option value="36">Pontevedra</option>\n<option value="37">Salamanca</option>\n<option value="38">Santa Cruz de Tenerife</option>\n<option value="39">Cantabria</option>\n<option value="40">Segovia</option>\n<option value="41">Seville</option>\n<option value="42">Soria</option>\n<option value="43">Tarragona</option>\n<option value="44">Teruel</option>\n<option value="45">Toledo</option>\n<option value="46">Valencia</option>\n<option value="47">Valladolid</option>\n<option value="48">Bizkaia</option>\n<option value="49">Zamora</option>\n<option value="50">Zaragoza</option>\n<option value="51">Ceuta</option>\n<option value="52">Melilla</option>\n</select>'
     341
     342"""
     343
  • tests/regressiontests/forms/tests.py

     
    99from localflavor.ch import tests as localflavor_ch_tests
    1010from localflavor.cl import tests as localflavor_cl_tests
    1111from localflavor.de import tests as localflavor_de_tests
     12from localflavor.es import tests as localflavor_es_tests
    1213from localflavor.fi import tests as localflavor_fi_tests
    1314from localflavor.fr import tests as localflavor_fr_tests
    1415from localflavor.generic import tests as localflavor_generic_tests
     
    3536    'localflavor_ch_tests': localflavor_ch_tests,
    3637    'localflavor_cl_tests': localflavor_cl_tests,
    3738    'localflavor_de_tests': localflavor_de_tests,
     39    'localflavor_es_tests': localflavor_es_tests,
    3840    'localflavor_fi_tests': localflavor_fi_tests,
    3941    'localflavor_fr_tests': localflavor_fr_tests,
    4042    'localflavor_generic_tests': localflavor_generic_tests,
Back to Top