diff --git a/AUTHORS b/AUTHORS index ec4a222a4efde..00e0c6fe929c6 100644 --- a/AUTHORS +++ b/AUTHORS @@ -67,6 +67,7 @@ answer newbie questions, and generally made Django that much better: Ian Clelland crankycoder@gmail.com Matt Croydon + flavio.curella@gmail.com Jure Cuhalev dackze+django@gmail.com Dirk Datzert diff --git a/django/contrib/localflavor/it/__init__.py b/django/contrib/localflavor/it/__init__.py new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/django/contrib/localflavor/it/forms.py b/django/contrib/localflavor/it/forms.py new file mode 100644 index 0000000000000..6760d91799325 --- /dev/null +++ b/django/contrib/localflavor/it/forms.py @@ -0,0 +1,32 @@ +""" +IT-specific Form helpers +""" + +from django.newforms import ValidationError +from django.newforms.fields import Field, RegexField, Select, EMPTY_VALUES +from django.newforms.util import smart_unicode +from django.utils.translation import gettext +import re + +class ITZipCodeField(RegexField): + def __init__(self, *args, **kwargs): + super(ITZipCodeField, self).__init__(r'^\d{5}$', + max_length=None, min_length=None, + error_message=gettext(u'Enter a zip code in the format XXXXX.'), + *args, **kwargs) + +class ITRegionSelect(Select): + """ + A Select widget that uses a list of IT regions as its choices. + """ + def __init__(self, attrs=None): + from it_region import REGION_CHOICES # relative import + super(ITRegionSelect, self).__init__(attrs, choices=REGION_CHOICES) + +class ITProvinceSelect(Select): + """ + A Select widget that uses a list of IT regions as its choices. + """ + def __init__(self, attrs=None): + from it_province import PROVINCE_CHOICES # relative import + super(ITProvinceSelect, self).__init__(attrs, choices=PROVINCE_CHOICES) diff --git a/django/contrib/localflavor/it/it_province.py b/django/contrib/localflavor/it/it_province.py new file mode 100644 index 0000000000000..1867191b31973 --- /dev/null +++ b/django/contrib/localflavor/it/it_province.py @@ -0,0 +1,114 @@ +# -*- coding: utf-8 -* + +PROVINCE_CHOICES = ( + ('AG', 'Agrigento'), + ('AL', 'Alessandria'), + ('AN', 'Ancona'), + ('AO', 'Aosta'), + ('AR', 'Arezzo'), + ('AP', 'Ascoli Piceno'), + ('AT', 'Asti'), + ('AV', 'Avellino'), + ('BA', 'Bari'), +# ('BT', 'Barletta-Andria-Trani'), # active starting from 2009 + ('BL', 'Belluno'), + ('BN', 'Benevento'), + ('BG', 'Bergamo'), + ('BI', 'Biella'), + ('BO', 'Bologna'), + ('BZ', 'Bolzano/Bozen'), + ('BS', 'Brescia'), + ('BR', 'Brindisi'), + ('CA', 'Cagliari'), + ('CL', 'Caltanissetta'), + ('CB', 'Campobasso'), + ('CI', 'Carbonia-Iglesias'), + ('CE', 'Caserta'), + ('CT', 'Catania'), + ('CZ', 'Catanzaro'), + ('CH', 'Chieti'), + ('CO', 'Como'), + ('CS', 'Cosenza'), + ('CR', 'Cremona'), + ('KR', 'Crotone'), + ('CN', 'Cuneo'), + ('EN', 'Enna'), +# ('FM', 'Fermo'), # active starting from 2009 + ('FE', 'Ferrara'), + ('FI', 'Firenze'), + ('FG', 'Foggia'), + ('FC', 'Forlì-Cesena'), + ('FR', 'Frosinone'), + ('GE', 'Genova'), + ('GO', 'Gorizia'), + ('GR', 'Grosseto'), + ('IM', 'Imperia'), + ('IS', 'Isernia'), + ('SP', 'La Spezia'), + ('AQ', u'L’Acquila'), + ('LT', 'Latina'), + ('LE', 'Lecce'), + ('LC', 'Lecco'), + ('LI', 'Livorno'), + ('LO', 'Lodi'), + ('LU', 'Lucca'), + ('MC', 'Macerata'), + ('MN', 'Mantova'), + ('MS', 'Massa-Carrara'), + ('MT', 'Matera'), + ('VS', 'Medio Campidano'), + ('ME', 'Messina'), + ('MI', 'Milano'), + ('MO', 'Modena'), +# ('MB', 'Monza e Brianza'), # active starting from 2009 + ('NA', 'Napoli'), + ('NO', 'Novara'), + ('NU', 'Nuoro'), + ('OG', 'Ogliastra'), + ('OT', 'Olbia-Tempio'), + ('OR', 'Oristano'), + ('PD', 'Padova'), + ('PA', 'Palermo'), + ('PR', 'Parma'), + ('PV', 'Pavia'), + ('PG', 'Perugia'), + ('PU', 'Pesaro e Urbino'), + ('PE', 'Pescara'), + ('PC', 'Piacenza'), + ('PI', 'Pisa'), + ('PT', 'Pistoia'), + ('PN', 'Pordenone'), + ('PZ', 'Potenza'), + ('PO', 'Prato'), + ('RG', 'Ragusa'), + ('RA', 'Ravenna'), + ('RC', 'Reggio Calabria'), + ('RE', 'Reggio Emilia'), + ('RI', 'Rieti'), + ('RN', 'Rimini') + ('RM', 'Roma'), + ('RO', 'Rovigo'), + ('SA', 'Salerno'), + ('SS', 'Sassari'), + ('SV', 'Savona'), + ('SI', 'Siena'), + ('SR', 'Siracusa'), + ('SO', 'Sondrio'), + ('TA', 'Taranto'), + ('TE', 'Teramo'), + ('TR', 'Terni'), + ('TO', 'Torino'), + ('TP', 'Trapani'), + ('TN', 'Trento'), + ('TV', 'Treviso'), + ('TS', 'Trieste'), + ('UD', 'Udine'), + ('VA', 'Varese'), + ('VE', 'Venezia'), + ('VB', 'Verbano Cusio Ossola'), + ('VC', 'Vercelli'), + ('VR', 'Verona'), + ('VV', 'Vibo Valentia'), + ('VI', 'Vicenza'), + ('VT', 'Viterbo'), +) diff --git a/django/contrib/localflavor/it/it_region.py b/django/contrib/localflavor/it/it_region.py new file mode 100644 index 0000000000000..0700b46ea8e98 --- /dev/null +++ b/django/contrib/localflavor/it/it_region.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -* + +REGION_CHOICES = ( + ('ABR', 'Abruzzo'), + ('BAS', 'Basilicata'), + ('CAL', 'Calabria'), + ('CAM', 'Campania'), + ('EMR', 'Emilia-Romagna'), + ('FVG', 'Friuli-Venezia Giulia'), + ('LAZ', 'Lazio'), + ('LIG', 'Liguria'), + ('LOM', 'Lombardia'), + ('MAR', 'Marche'), + ('MOL', 'Molise'), + ('PMN', 'Piemonte'), + ('PUG', 'Puglia'), + ('SAR', 'Sardegna'), + ('SIC', 'Sicilia'), + ('TOS', 'Toscana'), + ('TAA', 'Trentino-Alto Adige'), + ('UMB', 'Umbria'), + ('VAO', u'Valle d’Aosta'), + ('VEN', 'Veneto'), +)