diff --git a/django/contrib/localflavor/co/__init__.py b/django/contrib/localflavor/co/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/django/contrib/localflavor/co/co_departments.py b/django/contrib/localflavor/co/co_departments.py new file mode 100644 index 0000000000..f0989b6ba6 --- /dev/null +++ b/django/contrib/localflavor/co/co_departments.py @@ -0,0 +1,44 @@ +# -*- coding: utf-8 -*- +""" +A list of Colombian departaments as `choices` in a +formfield. + +This exists in this standalone file so that it's only +imported into memory when explicitly needed. +""" + +DEPARTMENT_CHOICES = ( + ('AMA', u'Amazonas'), + ('ANT', u'Antioquia'), + ('ARA', u'Arauca'), + ('ATL', u'Atlántico'), + ('DC', u'Bogotá'), + ('BOL', u'Bolívar'), + ('BOY', u'Boyacá'), + ('CAL', u'Caldas'), + ('CAQ', u'Caquetá'), + ('CAS', u'Casanare'), + ('CAU', u'Cauca'), + ('CES', u'Cesar'), + ('CHO', u'Chocó'), + ('COR', u'Córdoba'), + ('CUN', u'Cundinamarca'), + ('GUA', u'Guainía'), + ('GUV', u'Guaviare'), + ('HUI', u'Huila'), + ('LAG', u'La Guajira'), + ('MAG', u'Magdalena'), + ('MET', u'Meta'), + ('NAR', u'Nariño'), + ('NSA', u'Norte de Santander'), + ('PUT', u'Putumayo'), + ('QUI', u'Quindío'), + ('RIS', u'Risaralda'), + ('SAP', u'San Andrés and Providencia'), + ('SAN', u'Santander'), + ('SUC', u'Sucre'), + ('TOL', u'Tolima'), + ('VAC', u'Valle del Cauca'), + ('VAU', u'Vaupés'), + ('VID', u'Vichada'), +) diff --git a/django/contrib/localflavor/co/forms.py b/django/contrib/localflavor/co/forms.py new file mode 100644 index 0000000000..41e77b3a87 --- /dev/null +++ b/django/contrib/localflavor/co/forms.py @@ -0,0 +1,13 @@ +""" +Colombian-specific form helpers. +""" + +from django.forms.fields import Select + +class CODepartmentSelect(Select): + """ + A Select widget that uses a list of Colombian states as its choices. + """ + def __init__(self, attrs=None): + from co_departments import DEPARTMENT_CHOICES + super(CODepartmentSelect, self).__init__(attrs, choices=DEPARTMENT_CHOICES) diff --git a/django/contrib/localflavor/ec/__init__.py b/django/contrib/localflavor/ec/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/django/contrib/localflavor/ec/ec_provinces.py b/django/contrib/localflavor/ec/ec_provinces.py new file mode 100644 index 0000000000..7e55078be0 --- /dev/null +++ b/django/contrib/localflavor/ec/ec_provinces.py @@ -0,0 +1,35 @@ +# -*- coding: utf-8 -*- +""" +A list of Ecuador departaments as `choices` in a +formfield. + +This exists in this standalone file so that it's only +imported into memory when explicitly needed. +""" + +PROVINCE_CHOICES = ( + ('A', u'Azuay'), + ('B', u'Bolívar'), + ('F', u'Cañar'), + ('C', u'Carchi'), + ('H', u'Chimborazo'), + ('X', u'Cotopaxi'), + ('O', u'El Oro'), + ('E', u'Esmeraldas'), + ('W', u'Galápagos'), + ('G', u'Guayas'), + ('I', u'Imbabura'), + ('L', u'Loja'), + ('R', u'Los Ríos'), + ('M', u'Manabí'), + ('S', u'Morona Santiago'), + ('N', u'Napo'), + ('D', u'Orellana'), + ('Y', u'Pastaza'), + ('P', u'Pichincha'), + ('SE', u'Santa Elena'), + ('SD', u'Santo Domingo de los Tsáchilas'), + ('U', u'Sucumbíos'), + ('T', u'Tungurahua'), + ('Z', u'Zamora Chinchipe'), +) diff --git a/django/contrib/localflavor/ec/forms.py b/django/contrib/localflavor/ec/forms.py new file mode 100644 index 0000000000..d98b36c2cc --- /dev/null +++ b/django/contrib/localflavor/ec/forms.py @@ -0,0 +1,13 @@ +""" +Ecuador-specific form helpers. +""" + +from django.forms.fields import Select + +class ECProvinceSelect(Select): + """ + A Select widget that uses a list of Ecuador provinces as its choices. + """ + def __init__(self, attrs=None): + from ec_provinces import PROVINCE_CHOICES + super(ECProvinceSelect, self).__init__(attrs, choices=PROVINCE_CHOICES) diff --git a/docs/ref/contrib/localflavor.txt b/docs/ref/contrib/localflavor.txt index 60539e9663..78b997af6b 100644 --- a/docs/ref/contrib/localflavor.txt +++ b/docs/ref/contrib/localflavor.txt @@ -44,8 +44,10 @@ Countries currently supported by :mod:`~django.contrib.localflavor` are: * Canada_ * Chile_ * China_ + * Colombia_ * Croatia_ * Czech_ + * Ecuador_ * Finland_ * France_ * Germany_ @@ -98,8 +100,10 @@ Here's an example of how to use them:: .. _Canada: `Canada (ca)`_ .. _Chile: `Chile (cl)`_ .. _China: `China (cn)`_ +.. _Colombia: `Colombia (co)`_ .. _Croatia: `Croatia (hr)`_ .. _Czech: `Czech (cz)`_ +.. _Ecuador: `Ecuador (ec)`_ .. _Finland: `Finland (fi)`_ .. _France: `France (fr)`_ .. _Germany: `Germany (de)`_ @@ -392,6 +396,16 @@ China (``cn``) Valid formats are like 1XXXXXXXXXX, where X is digit. The second digit could only be 3, 5 and 8. +Colombia (``co``) +================= + +.. versionadded:: 1.4 + +.. class:: co.forms.CoDepartmentSelect + + A ``Select`` widget that uses a list of Colombian departments + as its choices. + Croatia (``hr``) ================ @@ -479,6 +493,16 @@ Czech (``cz``) A ``Select`` widget that uses a list of Czech regions as its choices. +Ecuador (``ec``) +================ + +.. versionadded:: 1.4 + +.. class:: ec.forms.EcProvinceSelect + + A ``Select`` widget that uses a list of Ecuatorian provinces as + its choices. + Finland (``fi``) ================ diff --git a/tests/regressiontests/forms/localflavor/co.py b/tests/regressiontests/forms/localflavor/co.py new file mode 100644 index 0000000000..a6240a3146 --- /dev/null +++ b/tests/regressiontests/forms/localflavor/co.py @@ -0,0 +1,43 @@ +from django.contrib.localflavor.co.forms import CODepartmentSelect + +from utils import LocalFlavorTestCase + +class COLocalFlavorTests(LocalFlavorTestCase): + def test_CODepartmentSelect(self): + d = CODepartmentSelect() + out = u"""""" + self.assertEqual(d.render('department', 'COR'), out) diff --git a/tests/regressiontests/forms/localflavor/ec.py b/tests/regressiontests/forms/localflavor/ec.py new file mode 100644 index 0000000000..83537af70b --- /dev/null +++ b/tests/regressiontests/forms/localflavor/ec.py @@ -0,0 +1,34 @@ +from django.contrib.localflavor.ec.forms import ECProvinceSelect + +from utils import LocalFlavorTestCase + +class ECLocalFlavorTests(LocalFlavorTestCase): + def test_ECProvinceSelect(self): + p = ECProvinceSelect() + out = u"""""" + self.assertEqual(p.render('province', 'U'), out) diff --git a/tests/regressiontests/forms/localflavortests.py b/tests/regressiontests/forms/localflavortests.py index 7f29feae3f..eb289b5a68 100644 --- a/tests/regressiontests/forms/localflavortests.py +++ b/tests/regressiontests/forms/localflavortests.py @@ -9,8 +9,10 @@ from localflavor.ch import CHLocalFlavorTests from localflavor.cl import CLLocalFlavorTests from localflavor.cz import CZLocalFlavorTests from localflavor.cn import CNLocalFlavorTests +from localflavor.co import COLocalFlavorTests from localflavor.de import DELocalFlavorTests from localflavor.es import ESLocalFlavorTests +from localflavor.ec import ECLocalFlavorTests from localflavor.fi import FILocalFlavorTests from localflavor.fr import FRLocalFlavorTests from localflavor.gb import GBLocalFlavorTests diff --git a/tests/regressiontests/forms/tests/__init__.py b/tests/regressiontests/forms/tests/__init__.py index 67154514d7..c45b25b374 100644 --- a/tests/regressiontests/forms/tests/__init__.py +++ b/tests/regressiontests/forms/tests/__init__.py @@ -21,8 +21,10 @@ from regressiontests.forms.localflavortests import ( CHLocalFlavorTests, CLLocalFlavorTests, CNLocalFlavorTests, + COLocalFlavorTests, CZLocalFlavorTests, DELocalFlavorTests, + ECLocalFlavorTests, ESLocalFlavorTests, FILocalFlavorTests, FRLocalFlavorTests,