Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed #8013 -- Added Columbian and Ecuadorian local flavor. Thanks, i…

…kks and Bernhard Essl.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@16570 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 4a6e1b56135b1a413576ea1a6d469387a1a5eb6d 1 parent 2ccfb6d
@jezdez jezdez authored
View
0  django/contrib/localflavor/co/__init__.py
No changes.
View
44 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'),
+)
View
13 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)
View
0  django/contrib/localflavor/ec/__init__.py
No changes.
View
35 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'),
+)
View
13 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)
View
24 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``)
================
View
43 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"""<select name="department">
+<option value="AMA">Amazonas</option>
+<option value="ANT">Antioquia</option>
+<option value="ARA">Arauca</option>
+<option value="ATL">Atl\xe1ntico</option>
+<option value="DC">Bogot\xe1</option>
+<option value="BOL">Bol\xedvar</option>
+<option value="BOY">Boyac\xe1</option>
+<option value="CAL">Caldas</option>
+<option value="CAQ">Caquet\xe1</option>
+<option value="CAS">Casanare</option>
+<option value="CAU">Cauca</option>
+<option value="CES">Cesar</option>
+<option value="CHO">Choc\xf3</option>
+<option value="COR" selected="selected">C\xf3rdoba</option>
+<option value="CUN">Cundinamarca</option>
+<option value="GUA">Guain\xeda</option>
+<option value="GUV">Guaviare</option>
+<option value="HUI">Huila</option>
+<option value="LAG">La Guajira</option>
+<option value="MAG">Magdalena</option>
+<option value="MET">Meta</option>
+<option value="NAR">Nari\xf1o</option>
+<option value="NSA">Norte de Santander</option>
+<option value="PUT">Putumayo</option>
+<option value="QUI">Quind\xedo</option>
+<option value="RIS">Risaralda</option>
+<option value="SAP">San Andr\xe9s and Providencia</option>
+<option value="SAN">Santander</option>
+<option value="SUC">Sucre</option>
+<option value="TOL">Tolima</option>
+<option value="VAC">Valle del Cauca</option>
+<option value="VAU">Vaup\xe9s</option>
+<option value="VID">Vichada</option>
+</select>"""
+ self.assertEqual(d.render('department', 'COR'), out)
View
34 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"""<select name="province">
+<option value="A">Azuay</option>
+<option value="B">Bol\xedvar</option>
+<option value="F">Ca\xf1ar</option>
+<option value="C">Carchi</option>
+<option value="H">Chimborazo</option>
+<option value="X">Cotopaxi</option>
+<option value="O">El Oro</option>
+<option value="E">Esmeraldas</option>
+<option value="W">Gal\xe1pagos</option>
+<option value="G">Guayas</option>
+<option value="I">Imbabura</option>
+<option value="L">Loja</option>
+<option value="R">Los R\xedos</option>
+<option value="M">Manab\xed</option>
+<option value="S">Morona Santiago</option>
+<option value="N">Napo</option>
+<option value="D">Orellana</option>
+<option value="Y">Pastaza</option>
+<option value="P">Pichincha</option>
+<option value="SE">Santa Elena</option>
+<option value="SD">Santo Domingo de los Ts\xe1chilas</option>
+<option value="U" selected="selected">Sucumb\xedos</option>
+<option value="T">Tungurahua</option>
+<option value="Z">Zamora Chinchipe</option>
+</select>"""
+ self.assertEqual(p.render('province', 'U'), out)
View
2  tests/regressiontests/forms/localflavortests.py
@@ -9,8 +9,10 @@
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
View
2  tests/regressiontests/forms/tests/__init__.py
@@ -21,8 +21,10 @@
CHLocalFlavorTests,
CLLocalFlavorTests,
CNLocalFlavorTests,
+ COLocalFlavorTests,
CZLocalFlavorTests,
DELocalFlavorTests,
+ ECLocalFlavorTests,
ESLocalFlavorTests,
FILocalFlavorTests,
FRLocalFlavorTests,
Please sign in to comment.
Something went wrong with that request. Please try again.